获取多维数组中的值详细信息



我需要一些帮助在php多维数组中获得基于天的数组元素。

这是我的数组:

Array ( [0] => Array ( [DOS] => Apr 2 2013 [Name] => Abc Starling [No] => 15616286[Duration] => 135 ) 
        [1] => Array ( [DOS] => Apr 2 2013 [Name] => Cde Starling [No] => 15616286[Duration] => 585 ) 
        [2] => Array ( [DOS] => Apr 3 2013 [Name] => Sdf Starling [No] => 15616286[Duration] => 123 )
        [3] => Array ( [DOS] => Apr 3 2013 [Name] => Sdc Starling [No] => 15616286[Duration] => 456 ) 
        [4] => Array ( [DOS] => Apr 4 2013 [Name] => Fcd Starling [No] => 15616286[Duration] => 789 )
        [5] => Array ( [DOS] => Apr 4 2013 [Name] => Rfd Starling [No] => 15616286[Duration] => 906 ) 
        [6] => Array ( [DOS] => Apr 5 2013 [Name] => Vfd Starling [No] => 15616286[Duration] => 567 )
        [7] => Array ( [DOS] => Apr 6 2013 [Name] => Gfr Starling [No] => 15616286[Duration] => 456 ) 
        [8] => Array ( [DOS] => Apr 6 2013 [Name] => Dvh Starling [No] => 15616286[Duration] => 343 ))

我想要今天Apr 3 2013的输出:

Array ( [0] => Array ( [DOS] => Apr 3 2013 [Name] => Sdf Starling [No] => 15616286[Duration] => 123 )
        [1] => Array ( [DOS] => Apr 3 2013 [Name] => Sdc Starling [No] => 15616286[Duration] => 456 )) 

试试array_filter:

$source=array(array("DOS"=>"Apr 3 2013","flag"=>"hit"),array("DOS"=>"Apr 4 2013","flag"=>"no hit"),array("DOS"=>"Apr 3 2013","flag"=>"hit"));
$cond="Apr 3 2013";
$result=array_filter($source,function($v)use($cond){
    return $v["DOS"]==$cond;
});
print_r($result);

现场演示


编辑:实时演示你的数组

foreach($arr as $key=>$val){
if($key['DOS'] =='Apr 3 2013'){
print_r($arr[$key]);
}
}

相关内容

  • 没有找到相关文章

最新更新