note 80226 added to function.array-splice

From: Date: Fri, 04 Jan 2008 20:43:14 +0000
Subject: note 80226 added to function.array-splice
Groups: php.notes 
Request: Send a blank email to php-notes+get-134782@lists.php.net to get a copy of this message
Just a heads-up: there's a big gotcha with array_splice() when trying to insert elements into an array without deleting any elements (in other words, when the $length parameter is zero). Tested on PHP 5.2.4, the last example from "Example#1 array_splice() examples" (above) FAILS. Instead of returning array("red", "green", "blue", "purple", "yellow"), instead it returns an empty array. Not sure if this is a bug, or the expected behavior has changed. $input = array("red", "green", "blue", "yellow"); array_splice($input, 3, 0, "purple"); Returns an empty array. ---- Server IP: 69.147.83.197 Probable Submitter: 38.101.48.18 ---- Manual Page -- http://www.php.net/manual/en/function.array-splice.php Edit -- https://master.php.net/note/edit/80226 Del: integrated -- https://master.php.net/note/delete/80226/integrated Del: useless -- https://master.php.net/note/delete/80226/useless Del: bad code -- https://master.php.net/note/delete/80226/bad+code Del: spam -- https://master.php.net/note/delete/80226/spam Del: non-english -- https://master.php.net/note/delete/80226/non-english Del: in docs -- https://master.php.net/note/delete/80226/in+docs Del: other reasons-- https://master.php.net/note/delete/80226 Reject -- https://master.php.net/note/reject/80226 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#134782) next »