"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>
字符串里的数据格式不对,你那个是以键值对的形式保存,而且还是字符串型的,矛盾了;