2014-04-16 57 views
-7
Array (
    [4] => Array (
     [0] => priyaa 
     [1] => aarthy 
    ) 
    [10] => Array (
     [0] => testa 
     [1] => test member 1 
    ) 
) 
+2

[RTFM](http://php.net/manual/en/control-structures.foreach.php) – George

回答

0

如果你不確定你將得到多少結果,那麼在循環中有一個循環。

例如...

$YourArray = array(); 
//Add to array here. 

foreach($YourArray as $LevelOne): 
    foreach ($LevelOne as $LevelTwo): 
    echo $LevelTwo . ' - '; 
    endforeach; 
    echo '<br>'; 
endforeach; 

會爲你輸出。

priyaa - aarthy 
testa - test member 1 
+0

我想輸出爲Priya => Aarthy和Testa =>測試成員 – usersk

+0

請參閱修正答案,這應該做它適合你。 –

+0

這個答案是有用的..但從上面的問題有一個數組內的兩個數組..但我不知道有多少個數組包括在單個數組..然後如何獲得? – usersk

0

試試這個,看看它是否解決您的問題

$array = array (
4 => array ( 
     0 => "priyaa" 
     1 => "aarthy" 
) 
10 => array (
     0 => "testa" 
     1 => "test member 1" 
    ) 
); 

foreach($array as $arr) { 
    foreach($arr as $val) { 
     echo $val; 
    } 
} 

乾杯!

相關問題