You are here: Re: [PHP] removing chars from string « PHP « IT news, forums, messages
Re: [PHP] removing chars from string

Posted by John Nichel on 06/27/05 19:07

Stut wrote:
> Jay Blanchard wrote:
>
>> 0-8 is nine characters, which is two less than eleven, IIRC
>
>
> So the length should be 9 not 8 no? Or should I go back to school?
>

Forgive us, it's Monday.

$newstring = substr ( $oldstring, 0, 9 );

Will knock the last two characters off of an eleven character string. 0
is the starting point, and 9 is the length you want returned....

$newstring = substr ( $oldstring, 1, 9 );

Will knock off the first and last character of an eleven character
string (giving you the 'middle' 9 characters).

$newstring = substr ( $oldstring, 0, -2 );

Will knock the last two characters off a string of any length.

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
john@kegworks.com

 

Navigation:

[Reply to this 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

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