Re: formatting form information

From: Date: Sat, 05 Aug 2000 04:51:28 +0000
Subject: Re: formatting form information
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-10236@lists.php.net to get a copy of this message
At 7:32 PM -0400 8/4/00, Daniel Convissor wrote:
Hi Craig: Craig Henderson wrote: is they will charge a different value. So I was thinking I could just use the explode() function to split apart the words and then count the number of elements in the array. However can explode() work with the space character? Try it. Write a quick test script, see what happens. By the way, you'll find it works and you can also use split(). Hmm, out of curiosity, anyone know which is better/faster/whatever? Or should I write a benchmark script and post the findings? Or, look in the mailing list archives.... http://marc.theaimsgroup.com/?l=php-general&m=95234884508191&w=2 Talks about the differences in what they do (matching via string v regular expression). DING! http://marc.theaimsgroup.com/?l=php-general&m=93815450714215&w=2 Says, explode is faster since it doesn't do full regular expressions.
Based on info gleaned from the mailing list, this is the relative speed order: SLOWER | eregi_xxx() # same as ereg, but case INsensitive | ereg_xxx(), split() # standard POSIX extended regexps | preg_xxx() # perl-style regexps | implode(), explode(), strxxx() functions FASTER I havent' done any benchmarks, though (if this needs to be corrected, feel free!). However, unless you are using some sort of horribly long & complex regular expression or are evaluating the regex in a loop with some relatively large # of iterations (eg, not 10...but 10,000 would qualify) the speed difference is probably negligible. If you are doing any database access, setting up the connection and running the queries will take far longer. If you are doing only a few regex evaluations in each program call, I wouldn't worry...use whatever form works best. -steve +--- "They've got a cherry pie there, that'll kill ya" ------------------+
| Steve Edberg                           University of California, Davis |
| sbedberg@ucdavis.edu                               Computer Consultant |
| http://aesric.ucdavis.edu/                  http://pgfsun.ucdavis.edu/ |
+-------------------------------------- FBI Special Agent Dale Cooper ---+

« previous php.general (#10236) next »