|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34244 The array_pop()-function doesn't take immediate arrays (like explode())
Submitted: 2005-08-25 02:58 UTC Modified: 2005-08-25 08:09 UTC
Avg. Score:3.0 ± 2.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: d-tail at msx dot org Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.1.0RC1 OS: Windows XP
Private report: No CVE-ID: None
 [2005-08-25 02:58 UTC] d-tail at msx dot org
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:
  $bread = "slice1.slice2.slice3.slice4";
  $last_slice = array_pop(explode(".", $bread));

Expected result:
Expect to see: "slice4"

  $bread = "slice1.slice2.slice3.slice4";
  $slices_array = explode(".", $bread);
  $last_slice = array_pop($slices_array);

Actual result:
Fatal error: Only variables can be passed by reference in D:\www\browser\index.php on line 46


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-25 03:16 UTC] d-tail at msx dot org
Another workaround is this:
  $bread = "slice1.slice2.slice3.slice4";
  $last_slice = array_pop(@explode(".", $bread));

Notice the '@' before the explode()-function.
 [2005-08-25 08:09 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue May 17 14:05:46 2022 UTC