Re: Re: String manipulation

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

 




On Nov 14, 2010, at 4:48 PM, Ron Piggott wrote:

Warning: strpos() [function.strpos]: Offset not contained in string


Shouldn't you check the length of the string before giving it the offset?

From: ash@xxxxxxxxxxxxxxxxxxxx

$pos = (strpos(' ', $string, 76))?strpos(' ',$string, 76):strlen($string);

Doesn't strpos(' ',$string,76) look for the first space to the *right* of position 76?

I really don't know how to do this except by exploding the string and shooting the array of characters, keeping mind of the last space found before you get to slot 75.

----- Reply message -----
From: "Ron Piggott" <ron.piggott@xxxxxxxxxxxxxxxxxx>

How would I write an IF statement that looks for the first space space (â â) left of the 76th character
^ left

in a string or <br>, which ever comes

first --- OR the end of the string (IE the string is less than 76 characters long? I specifically want is itâs character position in the string.



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