Traverse the array
<?php
$arr=array(
'Teaching Department'=>array(
) array(' Li','18','shemale'),
array('Gao','20','Male'),
array('Zhang','21 ','Monster'),
),
'Propaganda Department'=>array(
Array('Li','18','Shemale' ),
array('Gao','20','Male'),
array('Zhang','21','Yaoren'),
),
'Finance Department'=>array(
array('Li','18','Lady'),
array(' Gao','20','Male'),
array('Zhang','21','Yaoren'),
),
) ;
?>
I can’t figure it out. It’s different from what I thought. Please ask the teacher for help
<?php
##$arr=array( 'Teaching Department'=>array( array( 'Li','18','shemale'), array('Gao','20','Male'), array('Zhang',' 21','Monster'), ), 'Propaganda Department'=>array( array('Li','18','Shemale '), array('Gao','20','Male'), array('Zhang','21','Yaoren'),
foreach($arr as $ker=>$vase){ echo $ker.'< br/>'; foreach($vase as $k=>$v) { foreach($v as $x=>$y ) echo $y; '; } } Echo' & LT; br/& gt;#}
## e ==============='.'<br/>';}?> ;
I will obey you without paying anyone
foreach($arr as $key=> $value){
echo "Department".$key."<br>";
foreach($value as $ ke=>$va){
echo $ke."<br>";
foreach($va as $k =>$v){
echo $k.'--------'.$v."<br>";
}
}
}
This is a three-dimensional array, get it!
I won’t talk about the first loop, just get the index and value of the first layer;
The second loop is to get the index and value of the second loop, and the third loop is Get the index and value of the third loop
What effect do you want? Generally use foreach to traverse
I don’t understand what you want to do, traverse the array, how do you want to traverse it? What are the requirements?