With this:
private function jsonArray($object)
{
$json = array();
if(isset($object) && !empty($object))
{
foreach($object as $obj)
{
...
}
}
return $json;
}
We iterate over an object with success. We use PDO::fetch[FETCH_OBJ] and it works.
What if, we want to iterate over an array of objects like the one returned by a fetchAll with the FETCH_OBJ attribute? Should the syntax be the same?
Thanks in advance,
MEM
Can be as simple as having yet another foreach loop to iterate the array and then (“inside” that loop) do the same thing as before.