Re: removing chars from string

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

 



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@xxxxxxxxxxxx

--
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