| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
  [2005-08-25 02:58 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             | 
    |||||||||||||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 04:00:01 2025 UTC | 
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.