php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36590 list() function problem
Submitted: 2006-03-02 13:41 UTC Modified: 2006-03-02 13:45 UTC
From: peo at bsd-guide dot net Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.1.2 OS: OpenBSD 3.8
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: peo at bsd-guide dot net
New email:
PHP Version: OS:

 

 [2006-03-02 13:41 UTC] peo at bsd-guide dot net
Description:
------------
list() seems to fill in the variable values "backwards", which results in the array index variable being incremented before all values are assigned.


Reproduce code:
---------------
<?php
  $ads=array();

  $i=0;
  $date = "2006-01-30";
  $nr = "00423364";
  $file = "2006-01-30_00423364.jpg";
  list($ads[$i]['publ'],$ads[$i]['nr'],$ads[$i++]['fil']) = array($date,$nr,$file);

  print_r($ads);

?>


Expected result:
----------------
Array
(
    [0] => Array
        (
            [fil] => 2006-01-30_00423364.jpg
            [nr] => 00423364
            [publ] => 2006-01-30
        )

)

(as in 5.0.4)

Actual result:
--------------
Array
(
    [0] => Array
        (
            [fil] => 2006-01-30_00423364.jpg
        )

    [1] => Array
        (
            [nr] => 00423364
            [publ] => 2006-01-30
        )

)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-02 13:45 UTC] bjori@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Read the manual page
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Dec 07 00:00:01 2025 UTC