数组中的额外数据

时间:2014-04-24 11:00:01

标签: php arrays for-loop multidimensional-array echo

我创建了这个数组:

 $studentAssProg[]=array('studentID'=> $studentID,'assignmentID'=>$assignmentID,'assProgLevel'=>$progress);

打印progressLevel的最佳方法是什么,对于assignID =' 3' ?

2 个答案:

答案 0 :(得分:1)

foreach($studentAssProg as $data){
    if($data['assignmentID']==3){
         echo $data['assProgLevel'];
    }
}

答案 1 :(得分:0)

foreach($studentAssProg as $d) : 
    if($d['assignmentID'] == 3)
        echo $d['assProgLevel'];
endforeach;