我有一个数组的数组,格式如下:
$list = [ ["fdsa","1","fdsa"],["sadf","0","asdf"],["frfrf","0","sadfdsf"] ]
如何遍历每个值?
答案 0 :(得分:3)
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"
......除非你想要它更有条理......
答案 1 :(得分:-2)
尝试:
$array = array(array("!","Hello","World"));
foreach($array as $key){
$myvar = $key[0];
$myvar2 = $key[1];
$myvar3 = $key[2];
}
已更新!
希望它有所帮助!