Aarray And multiple array values

Aarray And multiple array values

array[key_element1] => array(1, 2,3);
array[key_element2] => array(4, 5, 6);

 associative arrays
array[key1] => array(key => value1, key => value2, key => value3);
array[key2] => array(key => value4, key => value5, key => value6);

Basically parsing the $values array and pulling the relevant value out.
 Unsetting the array as we go to leave only the values which were not
 sorted. The remaining items in the array will be merged after the loop.
 with array_merge.

PHP array

$values = array('value1', 'value2', 'value3', 'value4', 'value5', 'value6');
$keys = array(0, 2, 1, 5);

foreach ($keys AS $key) {
    $tempOutput[] = ($values[$key])?$values[$key]:'';
    unset($values[$key]);
}

$output = array_merge($tempOutput, $values);


Make new array be joining 2 arrays
shuffle($countries);
$n = count($countries); $i = 0;
$jumble = array();
foreach ($names as $name) {
    if (!isset($jumble[$name])) $jumble[$name] = array();
    $jumble[$name][] = $countries[$i++ % $n];
}