"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-PHP How to convert string type to array type

WBOY
WBOYOriginal
2016-11-30 23:59:521619browse

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>

Reply content:

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;
php-PHP How to convert string type to array type

php-PHP How to convert string type to array type

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn