note 97401 added to function.substr-replace
| From: | elloromtz at gmail dot com | Date: | Sun, 18 Apr 2010 06:23:55 +0000 |
| Subject: | note 97401 added to function.substr-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-168364@lists.php.net to get a copy of this message | ||
It's worth noting that when start and length are both negative -and- the length is less than or
equal to start, the length will have the effect of being set as 0.
substr_replace('eggs','x',-1,-1); //eggxs
substr_replace('eggs','x',-1,-2); //eggxs
substr_replace('eggs','x',-1,-2); //eggxs
Same as:
substr_replace('eggs','x',-1,0); //eggxs
substr_replace('huevos','x',-2,-2); //huevxos
substr_replace('huevos','x',-2,-3); //huevxos
substr_replace('huevos','x',-2,-3); //huevxos
Same as:
substr_replace('huevos','x',-2,0); //huevxos
Another note, if length is negative and start offsets the same position as length, length (yet
again) will have the effect as being set as 0. (Of course, as mentioned in the manual, when length
is negative it actually represents the position before it)
substr_replace('abcd', 'x', 0, -4); //xabcd
Same as:
substr_replace('abcd','x',0,0); //xabcd
substr_replace('abcd', 'x', 1, -3); //axbcd
Same as:
substr_replace('abcd', 'x', 1, 0); //axbcd
----
Server IP: 192.41.40.227
Probable Submitter: 98.198.217.142
----
Manual Page -- http://www.php.net/manual/en/function.substr-replace.php
Edit -- https://master.php.net/note/edit/97401
Del: integrated -- https://master.php.net/note/delete/97401/integrated
Del: useless -- https://master.php.net/note/delete/97401/useless
Del: bad code -- https://master.php.net/note/delete/97401/bad+code
Del: spam -- https://master.php.net/note/delete/97401/spam
Del: non-english -- https://master.php.net/note/delete/97401/non-english
Del: in docs -- https://master.php.net/note/delete/97401/in+docs
Del: other reasons-- https://master.php.net/note/delete/97401
Reject -- https://master.php.net/note/reject/97401
Search -- https://master.php.net/manage/user-notes.php