|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-10-20 15:17 UTC] esartoni at omniaglobal dot net
Description:
------------
foreach doesn't work as expected when using multidimensional arrays.
Reproduce code:
---------------
<?php
$a=array();
$a[]=array("one", "two", "three");
$a[]=array("five", "six", "seven");
// Code 1 (THIS DON'T WORK AS EXPECTED)
foreach ($a as $value) {
echo join(",", $value)."\n";
}
/*
This code below is a workaround:
// Code 2 (THIS WORKS!)
foreach ($a as $key => $value) {
echo join(",", $value)."\n";
}
*/
?>
Expected result:
----------------
one,two,three
five,six,seven
Actual result:
--------------
Array,0
Array,1
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 23 15:00:01 2025 UTC |
$a=array(1,2,3,4,5); foreach($a as $value) { echo $value."\n"; } OUTPUT: Array Array Array Array Array EXPECTED: 1 2 3 4 5