Converting associative arrays in PHP
969
I've been googling around and searching this forum but I haven't actually found a solution for what I need to achieve.
I'm getting an array from a db in this form
Array
(
[0] => Array
(
[0] => af
[1] => Afghanistan
)
[1] => Array
(
[0] => al
[1] => Algeria
)
)
I need it to look like this
Array
(
[af] => Afghanistan
[al] => Algeria
)
The db is sql server, this is the code I'm using to get the data
$sQueryCountries = "SELECT Country_Code,Country_Name FROM Countries WHERE Client_Id = '$client_id'";
$params = array();
$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
$rResultCountries = sqlsrv_query( $db, $sQueryCountries, $params, $options );
while ( $aRow = sqlsrv_fetch_array( $rResultCountries, SQLSRV_FETCH_NUMERIC ) )
{
$output[] = $aRow;
}
Answer
Solution:
Pretty basic array building in the fetch loop
Answer
Solution:
Try this :