[PHP-NOTES] note 130176 added to function.array-splice

[email protected] ("[email protected]")
Newsgroups php.notes
Message-ID <[email protected]>
Example 2 states the statement pairs are equivalent.

This is true only of the modified array. The *returns* from these pairs will never be equivalent.

The return of array_splice() is *always* an array of extracted values, even when nothing (empty array) or only 1 value is extracted.

<?php
$arr = [1, 2, 3, [4]];

$pop = $arr;
array_pop($pop): // [4]
$splice = $arr;
array_splice($splice, -1); // [ [4] ]

$unshift = $arr;
array_unshift($unshift, 'foo'): // 5
$splice = $arr;
array_splice($splice, 0, 0, 'foo'); // [ ]
?>
etc.
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 2601:404:cf00:51c:3003:cee:bf60:2e10)
----
Manual Page -- https://php.net/manual/en/function.array-splice.php
Edit        -- https://main.php.net/note/edit/130176
Del: integrated  -- https://main.php.net/note/delete/130176/integrated
Del: useless     -- https://main.php.net/note/delete/130176/useless
Del: bad code    -- https://main.php.net/note/delete/130176/bad+code
Del: spam        -- https://main.php.net/note/delete/130176/spam
Del: non-english -- https://main.php.net/note/delete/130176/non-english
Del: in docs     -- https://main.php.net/note/delete/130176/in+docs
Del: other reasons-- https://main.php.net/note/delete/130176
Reject      -- https://main.php.net/note/reject/130176
Search      -- https://main.php.net/manage/user-notes.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.