Understand PDO fetch and fetchAll iteration with foreach

TommyGun96

New Member
With this:\[code\]private function jsonArray($object){ $json = array(); if(isset($object) && !empty($object)) { foreach($object as $obj) { ... } } return $json;}\[/code\]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
 
Back
Top