Why is substr all over the board in how fast it processes the same string? Is it the server? Kind regards, Justin > -----Original Message----- > From: Robert Cummings [mailto:robert@xxxxxxxxxxxxx] > Sent: Tuesday, December 21, 2004 8:58 PM > To: justin.php.gen@xxxxxxxxxxxxxx > Cc: PHP-General; 'Curt Zirzow' > Subject: Re: FW: Accessing a Char in an Array > > > On Tue, 2004-12-21 at 23:47, Justin Palmer wrote: > > *Sorry Curt for sending this to you.* > > > > Hi, > > > > Well if any one is interested in the speed I set up an example that > > you can go to. Though, when I run the example substr() is very > > neurotic (or it seems that it is to me). It can process the > same line > > of code at a lot of different intervals, while accessing it > with {} is > > pretty consistant. > > > > What is the cause of this? > > > > I thought it might be the server, but would that not effect it for > > both tests (two others tests with objects)? > > > > By the by, during my testing I found that using {} to > access the first > > char in a string was anywhere from .5 to 4 times faster. > > {} is an operator whereas substr() is a function. Operators > are generally an order of magnitude faster than functions and > if all you want is the first character then {0} is much more > efficient than substr(). > > Cheers, > Rob. > -- > .------------------------------------------------------------. > | InterJinn Application Framework - http://www.interjinn.com | > :------------------------------------------------------------: > | An application and templating framework for PHP. Boasting | a > | powerful, scalable system for accessing system services | such as > | forms, properties, sessions, and caches. InterJinn | > | also provides an extremely flexible architecture for | > | creating re-usable components quickly and easily. | > `------------------------------------------------------------' > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php