note 118956 added to function.array-shift

From: Date: Mon, 07 Mar 2016 14:35:40 +0000
Subject: note 118956 added to function.array-shift
Groups: php.notes 
Request: Send a blank email to php-notes+get-205109@lists.php.net to get a copy of this message
This removeAdd function, the first argument shift your array then unshif the second argument to your array. first argument is an array and second argument can be int or str. <?php function removeAdd ($arr, $newer){ $a = array_shift($arr); $b = array_unshift($arr, $newer); foreach ($arr as $value){ echo $value."<br />"; } } $a = array(1,2,3,4,5,6); foreach ($a as $current){ echo $current."<br />"; } echo "<hr />"; removeAdd($a, 0); ?> OUTPUT: 1 2 3 4 5 6 _______ 0 2 3 4 5 6 ---- Server IP: 72.52.91.14 Probable Submitter: 46.209.90.228 ---- Manual Page -- http://php.net/manual/en/function.array-shift.php Edit -- https://master.php.net/note/edit/118956 Del: integrated -- https://master.php.net/note/delete/118956/integrated Del: useless -- https://master.php.net/note/delete/118956/useless Del: bad code -- https://master.php.net/note/delete/118956/bad+code Del: spam -- https://master.php.net/note/delete/118956/spam Del: non-english -- https://master.php.net/note/delete/118956/non-english Del: in docs -- https://master.php.net/note/delete/118956/in+docs Del: other reasons-- https://master.php.net/note/delete/118956 Reject -- https://master.php.net/note/reject/118956 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#205109) next »