note 80872 added to function.array-pop

From: Date: Tue, 05 Feb 2008 09:15:53 +0000
Subject: note 80872 added to function.array-pop
Groups: php.notes 
Request: Send a blank email to php-notes+get-135783@lists.php.net to get a copy of this message
@smp_info I think you are still tired. What would be wrong with: <?php $array = array('one', 'two', 'three', 'four'); //pop the last element off array_pop($array); //$array == array('one', 'two', 'three'); ?> As the documentation clearly notes, array_pop() not only returns the last element, but actually removes it from the array wich is passed by reference. Calling array_diff is a waste of resources. ---- Server IP: 83.137.20.135 Probable Submitter: 83.80.25.68 ---- Manual Page -- http://www.php.net/manual/en/function.array-pop.php Edit -- https://master.php.net/note/edit/80872 Del: integrated -- https://master.php.net/note/delete/80872/integrated Del: useless -- https://master.php.net/note/delete/80872/useless Del: bad code -- https://master.php.net/note/delete/80872/bad+code Del: spam -- https://master.php.net/note/delete/80872/spam Del: non-english -- https://master.php.net/note/delete/80872/non-english Del: in docs -- https://master.php.net/note/delete/80872/in+docs Del: other reasons-- https://master.php.net/note/delete/80872 Reject -- https://master.php.net/note/reject/80872 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#135783) next »