1$myArr = array("apple", "banana", "mango", "jackfruit");
2
3$toJSON = json_encode($myArr);
4
5echo $toJSON;
1<?php
2 // Loop through Array
3 $someArray = ...; // Replace ... with your PHP Array
4 foreach ($someArray as $key => $value) {
5 echo $value["name"] . ", " . $value["gender"] . "<br>";
6 }
7
8 // Loop through Object
9 $someObject = ...; // Replace ... with your PHP Object
10 foreach($someObject as $key => $value) {
11 echo $value->name . ", " . $value->gender . "<br>";
12 }
13?>
14