foreach loop through assoc array e.g. Joomla's repeatable form fields
public static function sortRepeatable($repeatable)
{
$repeatable = json_decode($repeatable);
$data = array();
if(!is_object($repeatable))
{
throw new BigwaveException('Repeatable must be of type object');
}
foreach($repeatable as $key => $item) :
foreach($item as $k => $i) :
if(empty($data[$k])) :
$data[$k] = new \stdClass;
endif;
$data[$k]->$key = $i;
endforeach;
endforeach;
return $data;
}