|
Posted by Andy Jeffries on 06/21/06 19:50
On Wed, 21 Jun 2006 21:39:26 +0200, Bent Stigsen wrote:
>>> On Wed, 21 Jun 2006 20:17:25 +0200, Juliette wrote:
>>>> The regex will still win, but I would guess this is slightly faster
>>>> than my earlier function.
>>>
>>> Indeed it is, this function runs in 0.4208 seconds making it the second
>>> fasted non-regex function.
>
> Thanks for doing all the stats so far, hope you have time for two more :)
Sue :-)
> I think you can save a few jiffies by skipping the last entry in the
> array, and just add it in the end. Saves you a comparison in the loop.
>
> Like:
>
> $array = explode ( ', ', $string );
> $arraycount = ( count($array)-1 );
> $string = '';
> for( $i=0; $i<$arraycount; $i++ ) {
> $string .= ((1&$i) ? ( $array[$i] . '; ' ) : ( $array[$i] . ', ' ));
> }
> $string .= $array[$i];
OK, you had the fastest non-regex function before this one.... and....
this one is slower (0.3638 seconds).
>> Changing my function to a while loop would probably take yet some more
>> of the timing, but I haven't really got the time to do so now.
And the while loop version takes 0.3587 seconds. So your 2nd non-regex
version still stands as the fastest non-regex version.
> So many ways. The thread should have been called "50 ways to change..."
LOL! :-)
Cheers,
Andy
--
Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
http://www.gphpedit.org | PHP editor for Gnome 2
http://www.andyjeffries.co.uk | Personal site and photos
Navigation:
[Reply to this message]
|