2015-07-20 72 views
-3

你知道從這個多維數組我如何檢索值(如字符串)的好方法或技巧:如何從多維數組中檢索值?

array (size=5) 
    0 => 
    array (size=1) 
     'email' => 
     array (size=1) 
     0 => string '[email protected]' (length=27) 
    1 => 
    array (size=1) 
    'email' => 
    array (size=1) 
     0 => string '[email protected]' (length=27) 
    2 => 
    array (size=1) 
    'email' => 
     array (size=1) 
     0 => string '[email protected]' (length=19) 
    3 => 
    array (size=1) 
    'email' => 
    array (size=1) 
     0 => string '[email protected]' (length=21) 
    4 => 
    array (size=1) 
    'email' => 
    array (size=1) 
     0 => string '[email protected]' (length=19) 
+2

傳統上,我們會寫一些代碼來做到這一點。 – 2015-07-20 03:00:13

回答

1

嘗試這樣的:

function fn($arg){ 
foreach ($arg as $key => $val){ 
    if (is_array($val)){ 
     fn($val); 
    } 
    else{ 
     echo "$key : $val\n"; 
    } 
} 
} 

fn($data); 
+0

有效簡單! –