array("..."=>"...") doesn't really as
Posted: Sun Apr 27, 2003 6:42 am
I am slightly dumbfounded. The code below assigns various keys and values to the array $countries.
However, when I var_dump the array I only get one value (see Output below).
Anyone got an idea why this is?
Output:
However, when I var_dump the array I only get one value (see Output below).
Anyone got an idea why this is?
Code: Select all
<?php
require_once("class_mysql.inc.php");
$sql=new mod_db;
$countries=array("Middle East"=>"Bahrain", "Middle East"=>"Egypt", "Middle East"=>"Iran", "Middle East"=>"Iraq", "Middle East"=>"Israel", "Middle East"=>"Jordan", "Middle East"=>"Kuwait", "Middle East"=>"Lebanon", "Middle East"=>"Oman", "Middle East"=>"Qatar", "Middle East"=>"Saudia Arabia", "Middle East"=>"Syria", "Middle East"=>"Turkey", "Middle East"=>"United Arab Emirates", "Middle East"=>"Yemen");
var_dump($countries);
foreach($countries as $key=>$value)
{
echo "<br><strong>Updating:</strong> $value as $key<br>";
echo $sql->update("countries","continent='$key'","country='".$value."'");
}
$query=$sql->query("SELECT * FROM countries WHERE continent='' ORDER BY country ASC");
while ($country=$sql->arrays("",$query))
{
echo """.$country[country]."", ";
}
?>Code: Select all
array(1) { ї"Middle East"]=> string(5) "Yemen" }
Updating: Yemen as Middle East