note 130176 added to function.array-splice

From: Date: Wed, 19 Mar 2025 21:10:51 +0000
Subject: note 130176 added to function.array-splice
Groups: php.notes 
Request: Send a blank email to php-notes+get-222008@lists.php.net to get a copy of this message
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

« previous php.notes (#222008) next »