Re: [PHP] file validation

2002-02-04 Thread Lars Torben Wilson
On Sun, 2002-02-03 at 14:06, Lars Torben Wilson wrote: > On Sun, 2002-02-03 at 12:12, Mike Frazer wrote: > > Your reply piqued my curiosity so I whipped together a script that times the > > execution of a foreach(), a while() and a for() loop executing the same > > commands. The results were rath

Re: [PHP] file validation

2002-02-03 Thread Lars Torben Wilson
On Sun, 2002-02-03 at 12:12, Mike Frazer wrote: > Your reply piqued my curiosity so I whipped together a script that times the > execution of a foreach(), a while() and a for() loop executing the same > commands. The results were rather surprising in some ways but not really > overall. > > The w

Re: [PHP] file validation

2002-02-03 Thread Mike Frazer
Your reply piqued my curiosity so I whipped together a script that times the execution of a foreach(), a while() and a for() loop executing the same commands. The results were rather surprising in some ways but not really overall. The while() loop is, as you stated, is quicker than a foreach() l

Re: [PHP] file validation

2002-02-03 Thread Lars Torben Wilson
On Sun, 2002-02-03 at 02:35, Mike Frazer wrote: > A slightly less cumbersome method than the while() loop below would be a > foreach() loop: > > function check_file($filename) { > if (!$lines = file($filename)) { > return false; > } > foreach ($lines as $line) { > $n

Re: [PHP] file validation

2002-02-02 Thread Mike Frazer
A slightly less cumbersome method than the while() loop below would be a foreach() loop: function check_file($filename) { if (!$lines = file($filename)) { return false; } foreach ($lines as $line) { $num_pipes = substr_count($line, '|'); if ($num_pipes < 2 ||

Re: [PHP] file validation

2002-02-01 Thread Lars Torben Wilson
On Fri, 2002-02-01 at 14:02, toni baker wrote: > I would like to prevent users from uploading a file > that contains more than 4 pipes or less than 2 pipes. > The code below prevents users from uploading a file > containing more than 4 pipes, but not less than 2 > pipes. Should I use awk, ereg, o

[PHP] file validation

2002-02-01 Thread toni baker
I would like to prevent users from uploading a file that contains more than 4 pipes or less than 2 pipes. The code below prevents users from uploading a file containing more than 4 pipes, but not less than 2 pipes. Should I use awk, ereg, or sed? Thanks system ("/bin/cat $userfile|/bin/sed -n