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