note 40407 added to function.substr

From: Date: Wed, 03 Mar 2004 05:30:08 +0000
Subject: note 40407 added to function.substr
Groups: php.notes 
Request: Send a blank email to php-notes+get-66141@lists.php.net to get a copy of this message
If you are only trying to get ONE letter, using $var[4] is actaully faster than substr($var,4,1). I am confused as to why this is, because it makes sense that converting the string to an array will be slow. But, it has been confirmed in a 100 000 trial test, with strings ranging in length from 1 to 100 000 characters. If anyone knows why this is true, please let me know. ---- Manual Page -- http://www.php.net/manual/en/function.substr.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+40407 Delete -- http://master.php.net/manage/user-notes.php?action=delete+40407&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+40407&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#66141) next »