views:

50

answers:

1

What I want to do is:

$array_data = array( "a" => array(1, 2, 3), "b" => array( 1, 2, 3 ) );

$table_converted = CONVERT_TO_MYSQL_TABLE( $array_data );

while ($row = mysql_fetch_assoc( $table_converted )) {
       echo $row['a'] . " union " . $row['b'];
}

Thanks!

A: 

Loop through the array, and construct an array with the same keys but in different order:

$array_data = array( "a" => array(1, 2, 3), "b" => array( 1, 2, 3 ) );

$results = array();
foreach ($array_data as $name => $values)
{
    foreach ($values as $i => $value)
    {
        $results[$i][$name] = $value;
    }
}
print_r($results);
Sjoerd