* Thus wrote Justin Palmer: > Why is substr all over the board in how fast it processes the same > string? Is it the server? Benchmarking can be a funny thing. Usually benchmarks take an average of serveral thousand iterations in order to find the average time it take something to do. Benchmarking with the output of a browser can lead to different results on each request for a varity of reasons like: 1) processor load (and capacity) at the time 2) memory allocation for the paticular request (which will vary uppon each request) 3) something I overlooked. Another thing to note is that there generally is more overhead on the first few routines of a benchmark, try swapping your test so that the 'String Array' is done first. Another thing to note is your test script has a lot of things that can factor speed issues. In order to test the difference between to different methods you want to set something up like: <?php // initialize variable before time testing // so memory allocation issues are avoided. $i=0; $var = ' '; $str = 'a b c d'; //start timer for($i=0; $i <= 1000; $i++ ) { $var = $str{0}; } //end timer //start timer for($i=0; $i <= 1000; $i++ ) { $var = substr($str, 0, 1); } //end timer Then check the results, record them and swap the two benchmarks. check the results and record. All in all, you probably will still see that the $str{0} is faster, and as mentioned, its because its substr() is a function and $str{0} is handled by the Zend Engine. A time of substr result = 0.0000370000, is rather quick and is can be assumed that there is a large amount of error (based on the level of accuracy we are dealing with). On my 450hz machine I wont accept a page that takes longer than 0.100 to execute. Which is a very long time compared to the 0.000034 for substr(). HTH, Curt. Curt -- Quoth the Raven, "Nevermore." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php