32, "Quagmire"=>30, "Joe"=>34要用array("Peter"=>32, "Quagmire"=>30"/> 32, "Quagmire"=>30, "Joe"=>34要用array("Peter"=>32, "Quagmire"=>30">

Home >Backend Development >PHP Tutorial >用array生成关联数组是括号内是字符串怎么处理

用array生成关联数组是括号内是字符串怎么处理

WBOY
WBOYOriginal
2016-06-13 10:16:531261browse

用array生成关联数组是括号内是字符串怎么办?
是这样的,从数据库中读出的值是:
"Peter"=>32, "Quagmire"=>30, "Joe"=>34
要用array("Peter"=>32, "Quagmire"=>30, "Joe"=>34),把它变为关联数组,但是都出来的值是字符串,有没有办法去除字符串的属性?或者有其他办法保存?

非常感谢!

------解决方案--------------------

PHP code
<?php $str='"Peter"=>32, "Quagmire"=>30, "Joe"=>34';eval('$arr=array('.$str.');');print_r($arr);<div class="clear">
                 
              
              
        
            </div>
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