1$clothes = array("hat","shoe","shirt");
2foreach ($clothes as $item) {
3 echo $item;
4}
1$arr = array(1, 2, 3, 4);
2foreach ($arr as &$value) {
3 $value = $value * 2;
4}
1for ($i = 0; $i < count($array); $i++) {
2 echo $array[$i]['filename'];
3 echo $array[$i]['filepath'];
4}
1const avengers = ['thor', 'captain america', 'hulk'];
2avengers.forEach((item, index)=>{
3 console.log(index, item)
4})
1foreach (array_expression as $value)
2 statement
3foreach (array_expression as $key => $value)
4 statement
5
1 $userDetails = array(
2 "name" => "Salam Ali Ahasan",
3 "education" => "MSC",
4 "email" => "oti.007@gmail.com",
5 "skills" => "Php",
6 "experience" => "7 years",
7 "location" => "Dhaka, Bangladesh",
8 "profession" => "Programmer"
9);
10
11if(isset($userDetails)){
12 foreach ($userDetails as $userDetailsValue) {
13 echo $name=$userDetailsValue['name'];
14 echo $education=$userDetailsValue['education'];
15 echo $email=$userDetailsValue['email'];
16 echo $skills=$userDetailsValue['skills'];
17 echo $experience=$userDetailsValue['experience'];
18 echo $location=$userDetailsValue['location'];
19 echo $profession=$userDetailsValue['profession'];
20 }
21 }