1$clothes = array("hat","shoe","shirt");
2foreach ($clothes as $item) {
3 echo $item;
4}
1foreach($array as $i => $item) {
2 echo $item[$i]['filename'];
3 echo $item[$i]['filepath'];
4
5 // $array[$i] is same as $item
6}
1foreach (array as $value){
2 //code to be executed;
3 print("value : $value");
4}
5
6foreach (array as $key => $value){
7 //code to be executed;
8 print("key[$key] => $value");
9}
1foreach (array_expression as $value)
2 statement
3foreach (array_expression as $key => $value)
4 statement
1foreach($array as $item) {
2 echo $item['filename'];
3 echo $item['filepath'];
4
5 // to know what's in $item
6 echo '<pre>'; var_dump($item);
7}