php-PHP How to convert string type to array type

WBOY
Release: 2023-03-01 13:38:01
Original
1522 people have browsed it

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>
Copy after login

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

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!