-2

我有一个数组,格式如下:

$list = [ ["fdsa","1","fdsa"],["sadf","0","asdf"],["frfrf","0","sadfdsf"] ]

如何循环遍历每个值?

4

2 回答 2

3

带一个RecursiveIteratorIterator

foreach(new RecursiveIteratorIterator(new RecursiveArrayIterator($list)) as $item){
        var_dump($item);
}

string(4) "fdsa"
string(1) "1"
string(4) "fdsa"
string(4) "sadf"
string(1) "0"
string(4) "asdf"
string(5) "frfrf"
string(1) "0"
string(7) "sadfdsf"

...除非您希望它更有条理...

于 2013-10-15T21:33:35.377 回答
-2

尝试:

$array = array(array("!","Hello","World"));
foreach($array as $key){
    $myvar = $key[0];
    $myvar2 = $key[1];
    $myvar3 = $key[2];
}

更新!

希望它有所帮助!

于 2013-10-15T21:44:29.933 回答