private function jsonArray($object)
{
$json = array();
if(isset($object) && !empty($object))
{
foreach($object as $obj)
{
$json[]["name"] = $obj;
}
}
return $json;
}
We are grabbing an object, and if the conditional is met, we iterate over that object.
Then… I’m lost on this reading… :s
What’s the meaning of the [] here?
$json[]["name"] = $obj;
Thanks in advance,
MEM
$json[]adds an element at the end of the array (numeric index). It’s the same as having the following code: