Home > Backend Development > PHP Tutorial > 输出数组不加单引号,该怎么处理

输出数组不加单引号,该怎么处理

WBOY
Release: 2016-06-13 11:50:57
Original
1439 people have browsed it

输出数组不加单引号

本帖最后由 kay89757sc 于 2014-03-15 03:06:33 编辑
<br />//数据库连接 <br />$rs = mysql_query("select id,degree,min,max,prize,v from magic_config"); <br />	while($r = mysql_fetch_assoc($rs)) {  <br />	$prize_arr[] = $r; } 
Copy after login

如何让输出的数组其中的degree获取的数字不加单引号呢?

<br />$prize_arr = array( <br />		array('id'=>'1','degree'=>97,'min'=>'1','max'=>'5','prize'=>'不要放弃','v'=>'1'), <br />		array('id'=>'2','degree'=>98,'min'=>'7','max'=>'35','prize'=>'不要灰心','v'=>'1'),); 
Copy after login

97 98 这样的不要单引号
------解决方案--------------------
$prize_arr = array( <br />        array('id'=>'1','degree'=>97,'min'=>'1','max'=>'5','prize'=>'不要放弃','v'=>'1'), <br />        array('id'=>'2','degree'=>98,'min'=>'7','max'=>'35','prize'=>'不要灰心','v'=>'1'),); <br />foreach ($prize_arr as $key => $value) {<br />	$prize_arr[$key]['degree'] = (int) $value['degree'];<br />}<br />var_dump($prize_arr);
Copy after login

其实没必要转的 php是弱语言字符和整形没多大区别
Related labels:
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