我有这个数组:
$age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
它打印,这没关系:
Array ( [Peter] => 35 [Ben] => 37 [Joe] => 43 )
但我想从字符串中添加值,如下所示:
$string = '"Peter"=>"35", "Ben"=>"37", "Joe"=>"43"';
$age = array($string);
问题在于它打印:
Array ( [0] => "Peter"=>"35", "Ben"=>"37", "Joe"=>"43" )
我不想要这个:
[0] =>
钥匙不对。它不会变成""到[]:
Right: [Peter] => ...
Wrong: "Peter" => ...
我该怎么办?