"1988","Li Si"=>"1990","Wang Wu"=>"1989")'; foreach($arr as $key => $value){ echo "Name:".$key."-Year:&quo"/> "1988","Li Si"=>"1990","Wang Wu"=>"1989")'; foreach($arr as $key => $value){ echo "Name:".$key."-Year:&quo">
Home >Backend Development >PHP Tutorial >php-PHP How to convert string type to array type
php
$arr is a string type, and the single quotes are array syntax. How to convert this string to an array type?
<code>$arr = 'array("张三"=>"1988","李四"=>"1990","王五"=>"1989")';foreach($arr as $key => $value){ echo "姓名:".$key."-年份:".$value."<br>";}</code>
The data format in the string is wrong. Yours is saved in the form of key-value pairs, and it is also a string type, which is contradictory;