#34244 [Opn]: The array_pop()-function doesn't take immediate arrays (like explode())

From: Date: Thu, 25 Aug 2005 01:16:50 +0000
Subject: #34244 [Opn]: The array_pop()-function doesn't take immediate arrays (like explode())
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-83966@lists.php.net to get a copy of this message
ID: 34244 User updated by: d-tail at msx dot org Reported By: d-tail at msx dot org Status: Open Bug Type: Arrays related Operating System: Windows XP PHP Version: 5.1.0RC1 New Comment: Another workaround is this: <?php $bread = "slice1.slice2.slice3.slice4"; $last_slice = array_pop(@explode(".", $bread)); echo($last_slice); ?> Notice the '@' before the explode()-function. Previous Comments: ------------------------------------------------------------------------ [2005-08-25 02:58:28] d-tail at msx dot org Description: ------------ The array_pop()-function (and most likely, similar array operators) doesn't take immediate arrays anymore, that is, arrays without a variable name. It worked in previous versions, though. Reproduce code: --------------- <?php $bread = "slice1.slice2.slice3.slice4"; $last_slice = array_pop(explode(".", $bread)); echo($last_slice); ?> Expected result: ---------------- Expect to see: "slice4" Workaround: <?php $bread = "slice1.slice2.slice3.slice4"; $slices_array = explode(".", $bread); $last_slice = array_pop($slices_array); echo($last_slice); ?> Actual result: -------------- Fatal error: Only variables can be passed by reference in D:\www\browser\index.php on line 46 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=34244&edit=1

« previous php.bugs (#83966) next »