我有像这样的数组
$data = array(
"some" => "163",
"rand" => "630",
"om" => "43",
"words" => "924",
"as" => "4",
"keys" => "54"
);
如何将每个组的键与相关联的与相关联:
foreach ($data as $stuff){
$this->$stuff["key"] = $stuff["value"];
}
答案 0 :(得分:16)
foreach ($data as $key => $value){
echo "$key => $value\n";
}
答案 1 :(得分:5)
foreach($data as $key => $value)
{
// $key and $value variable are available here
// First iteration values would be: $key = "some" and $value = "163"
}