Re[2]: [PHP] removing chars from string
| From: | Richard Davey | Date: | Mon, 27 Jun 2005 16:29:44 +0000 |
| Subject: | Re[2]: [PHP] removing chars from string | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-217702@lists.php.net to get a copy of this message | ||
Hello Stut,
Monday, June 27, 2005, 4:59:17 PM, you wrote:
>> 0-8 is nine characters, which is two less than eleven, IIRC
S> So the length should be 9 not 8 no? Or should I go back to school?
It should be 9 if you want 9 characters.
Lots of PHP functions are zero-based, but the 3rd parameter to substr
is asking for the number of characters to return, not the actual
character location in the string to stop at - if it did, then it would
have been 8 (0 being the 1st character, etc), but in this case it's 9.
It's an easy one to slip-up on imho.
Best regards,
Richard Davey
--
http://www.launchcode.co.uk - PHP Development Services
"I do not fear computers. I fear the lack of them." - Isaac Asimov