note 81491 added to function.substr
| From: | kriskra at gmail dot com | Date: | Sat, 01 Mar 2008 01:21:51 +0000 |
| Subject: | note 81491 added to function.substr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-136624@lists.php.net to get a copy of this message | ||
The javascript charAt equivalent in php of felipe has a little bug. It's necessary to compare
the type (implicit) aswell or the function returns a wrong result:
<?php
function charAt($str,$pos) {
return (substr($str,$pos,1) !== false) ? substr($str,$pos,1) : -1;
}
?>
----
Server IP: 212.124.37.9
Probable Submitter: 217.233.180.62
----
Manual Page -- http://www.php.net/manual/en/function.substr.php
Edit -- https://master.php.net/note/edit/81491
Del: integrated -- https://master.php.net/note/delete/81491/integrated
Del: useless -- https://master.php.net/note/delete/81491/useless
Del: bad code -- https://master.php.net/note/delete/81491/bad+code
Del: spam -- https://master.php.net/note/delete/81491/spam
Del: non-english -- https://master.php.net/note/delete/81491/non-english
Del: in docs -- https://master.php.net/note/delete/81491/in+docs
Del: other reasons-- https://master.php.net/note/delete/81491
Reject -- https://master.php.net/note/reject/81491
Search -- https://master.php.net/manage/user-notes.php