Hi,
I have a couple of MySQL tables setup like so:
Table Name: location
Field key Value
------------| --------------------------
0 Ongar, Essex
1 Richmond, London
2 Brentwood, Essex
3 Romford, Essex
Table Name: date
Field key Value
------------| --------------------------
0 04/10/2012
1 10/11/2012
2 04/06/2012
3 05/09/2012
I’m currently looping through both tables like so:
foreach($_SESSION['cv_builder']['array_field_list'] as $table_name)
{
$subset_array = $this->dbh->getAll("select field_key,value from ".TABLE_PREFIX."cv_builder_".$table_name." where sessionid='".mysql_real_escape_string($_SESSION['cv_builder']['sessionid'])."'", DB_FETCHMODE_ASSOC);
}
Now what i’m looking to achieve is to merge the arrays by the field_key field. So, the array I would like to end up with should look like so:
array(
[0] =>
array(
[location] => 'Ongar, Essex',
[date] => '04/10/2012'
)
[1] =>
array(
[location] => 'Richmond, London',
[date] => '10/11/2012'
)
[2] =>
array(
[location] => 'Brentwood, Essex',
[date] => '04/06/2012'
)
[3] =>
array(
[location] => 'Romford, Essex',
[date] => '05/09/2012'
)
)
Any idea how to get to this output?
Thanks.