aaaaaaaa=bbbbbbbbb
how to find out is "=" 14th char or 16th char ??? ... in a textarea row
[man]strpos/man
under ideal circumstances:
$string = "aaaaaaaa=bbbbbbbbb"; $array = explode("=", $string); $count = strlen($array[0])+1; echo $count;
edit: strpos() is a much, much, better approach...
ideal circumstances ... 🙂
[MOD EDIT: Posting personal contact information isn't allowed by the administrators - please use private messages if you would like to exchange such information with other members]
THANKS
$str = "aaaaaaaa=bbbbbbbbb"; echo strpos($str, '=')+1;
Output:
9
Unless it is absolutely certain that '=' is in the string, the return value of strpos() should be checked.
E.g.:
echo ($loc = strpos($str, '=')) !== FALSE ? $loc + 1 : 'not found!';
Is "=" the 14th or 16th character?
if($string[13]=='=' || $string[15]=='=') { echo "yes"; } else { echo "no"; }
Remembering that character positions are counted starting from 0.
That would need a check with strlen() or isset as well, otherwise the string might be accessed out of bounds (but at least that is not so bad in PHP).