Re[2]: removing chars from string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux