note 68767 added to function.array-shift

From: Date: Thu, 10 Aug 2006 03:13:36 +0000
Subject: note 68767 added to function.array-shift
Groups: php.notes 
Request: Send a blank email to php-notes+get-115744@lists.php.net to get a copy of this message
I haven't really read into it, but if you're complaining about a change in PHP 5.0.5 that made it so you couldn't do: <?php $val = array_shift(preg_split()); ?> or <?php $val = array_shit(function_that_returns_array); ?> Then you're not using this function correctly. This function's argument is supposed to be a pointer to a variable. It then modifies that variable and returns a value. When you specify a function, php CAN NOT modify the return value of that function. It should be common sense but apparently its not. Also, on a efficiency note, you might want to consider using another function such as reset or perhaps making your own function such as below: <?php function first_element($array) { return reset($array); } ?> Unless of course for some reason you need to save the microseconds this takes. } ---- Server IP: 64.71.164.2 Probable Submitter: 69.1.58.20 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.array-shift.php Edit -- https://master.php.net/note/edit/68767 Del: integrated -- https://master.php.net/note/delete/68767/integrated Del: useless -- https://master.php.net/note/delete/68767/useless Del: bad code -- https://master.php.net/note/delete/68767/bad+code Del: spam -- https://master.php.net/note/delete/68767/spam Del: non-english -- https://master.php.net/note/delete/68767/non-english Del: in docs -- https://master.php.net/note/delete/68767/in+docs Del: other reasons-- https://master.php.net/note/delete/68767 Reject -- https://master.php.net/note/reject/68767 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#115744) next »