"1988","李四"=>"1990","王五"=>"1989")'; foreach($arr as $key => $value){ echo "姓名:".$key."-年份:&quo"/> "1988","李四"=>"1990","王五"=>"1989")'; foreach($arr as $key => $value){ echo "姓名:".$key."-年份:&quo">
php
$arr是字串類型,單引號中是陣列語法,如何將該字串轉換為陣列類型?
<code>$arr = 'array("张三"=>"1988","李四"=>"1990","王五"=>"1989")';foreach($arr as $key => $value){ echo "姓名:".$key."-年份:".$value."<br>";}</code>
字串裡的資料格式不對,你那個是以鍵值對的形式保存,而且還是字串型的,矛盾了;