note 97097 added to function.array-splice
| From: | news_yodpeirs at thoftware dot de | Date: | Thu, 01 Apr 2010 09:32:29 +0000 |
| Subject: | note 97097 added to function.array-splice | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-167611@lists.php.net to get a copy of this message | ||
Splicing with NULL as replacement may result in unexpected behavior too. Typecasting NULL into an
array results in an empty array (as "(array)NULL" equals "array()"). That means,
instead of creating an element with value NULL just no new element ist created (just as if there was
no replacement specified).
If you want the splicing to create a new element with value NULL you have to use
"array(NULL)" instead of NULL.
You should expect this if you read the explanation carefully, but just as objects are considered as
a special case for replacement, NULL should be too.
The explanation of replacement better should read: "If replacement is just one element it is
not necessary to put array() around it, unless the element is an array itself, an object or
NULL."
And the note better should be: "If replacement is not an array, it will be typecast to one
(i.e. (array) $parameter). This may result in unexpected behavior when using an object or NULL
replacement."
jmtc
----
Server IP: 217.160.235.204
Probable Submitter: 80.153.162.95
----
Manual Page -- http://www.php.net/manual/en/function.array-splice.php
Edit -- https://master.php.net/note/edit/97097
Del: integrated -- https://master.php.net/note/delete/97097/integrated
Del: useless -- https://master.php.net/note/delete/97097/useless
Del: bad code -- https://master.php.net/note/delete/97097/bad+code
Del: spam -- https://master.php.net/note/delete/97097/spam
Del: non-english -- https://master.php.net/note/delete/97097/non-english
Del: in docs -- https://master.php.net/note/delete/97097/in+docs
Del: other reasons-- https://master.php.net/note/delete/97097
Reject -- https://master.php.net/note/reject/97097
Search -- https://master.php.net/manage/user-notes.php