I don't even know if that's the right term for what I want... In the array below, I want to create an array based on the values of one element and the keys of another...
This is the original array:
Array
(
[storage] => Array
(
[data] => Array
(
[0] => Array
(
[0] => Joe
[1] => Blow
[2] => x@x.com2
[3] => 5555555555
[4] => Mr.
)
[1] => Array
(
[0] => John
[1] => Doe
[2] =>
[3] => 5555555555
[4] => Dr.
)
)
[group] => 11
[type] => 0
)
[submitted] => 1
[values] => Array
// The values of the keys below match up with the keys in array['storage']['data']
(
[fn] => 0
[ln] => 1
[em] => 2
[mo] => 3
[ti] => 4
)
So, for each array in array['storage']['data'], I want to match the values up to the keys in array['values'] (based on the keys of array['storage']['data'] and the values of array['values']) so that I wind up with an array that looks like this:
Array
(
[0] => Array (
[Joe] => fn
[Blow] => ln
[x@x.com2] =>em
[5555555555] => mo
[Mr.] => ti
)
[1] => Array (
[John] => fn
[Doe] => ln
[] => em
[5555555555] => mo
[Dr.] => ti
)
I tried this, but it didn't work, even though it echoed correctly:
$maparray = array();
$valuearray = array("fn","ln","em","mo","ti");
$i = 0;
foreach($form_state['storage']['data'][$i] as $key => $value) {
foreach($form_state['values'] as $key2 => $value2) {
if(in_array($key2, $valuearray)) {
if($key == $value2) {
echo 'maparray['.$i.']['.$value.'] = '.$key2.'<br />';
$maparray[$value] = $key2;
}
}
}
$i++;
}