sigil88
2/21/2017 - 3:49 PM

group assoc array by key & foreach loop through From here: http://joomla.stackexchange.com/questions/9721/get-value-from-a-repeatable-field-

// Firstly, get the json object for the parameter like so:

$mitarbeiter = $params->get('mitarbeiter');

// Then decode the json object:

$json = json_decode($mitarbeiter, true);

// Then can then group each set of fields by key, like so:

public function group_by_key($array) 
{
    $result = array();

    foreach ($array as $sub) 
    {
        foreach ($sub as $k => $v) 
        {
            $result[$k][] = $v;
        }
    }
    return $result;
}

$filtered_array = group_by_key($json);

// And finally, you'll need to iterate though it using a foreach loop, like so:

foreach ($filtered_array as $index=>$value) 
{   
    echo $value[0] . '<br>';   // mitarbeitername
    echo $value[1] . '<br>';   // mitarbeiterfunktion
    echo $value[2] . '<br>';   // mitarbeitertelefonnummer
    echo $value[3] . '<br>';   // mitarbeiteremail
    echo $value[4] . '<br>';   // mitarbeiterbild
}