Reply to Re[2]: [PHP] removing chars from string

Your name:

Reply:


Posted by Richard Davey on 06/27/05 19:29

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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация