我是 PHP 新手,在下面的代码中 $strng 值是为数组动态创建的。
$strng='"Active Life" => "6","Arts & Entertainment" => "4","Beauty & Spa" => "3","Food & Drink" => "1","Hotels" => "10","Local Services" => "8","Nightlife" => "2","Pets" => "9","Public Services" => "7","Shopping" => "5"';
$bussCatry=array($strng);
foreach($bussCatry as $x=>$x_value)
{
error_log( "Key=" . $x . ", Value=" . $x_value);
}
但是当我尝试创建数组时,我失败了,我的输出低于预期。只有一个键值对
Key=0,
Value="Active Life" =>"6",
"Arts & Entertainment" =>"4",
"Beauty & Spa" =>"3",
"Food & Drink" =>"1",
"Hotels" =>"10",
"Local Services" =>"8",
"Nightlife" =>"2",
"Pets" =>"9",
"Public Services" =>"7",
"Shopping" =>"5"