Home > Backend Development > PHP Tutorial > 求大神指导一二

求大神指导一二

WBOY
Release: 2016-06-13 11:50:33
Original
869 people have browsed it

求大神指点一二
数据库连接

$rs = mysql_query("select id,degree,min,max,prize,v from magic_config");<br />while($r = mysql_fetch_assoc($rs)) {<br /> $prize_arr[] = $r;<br />}<br />print_r($prize_arr);
Copy after login

看了下 出来的是
Array (
[0] => Array ( [id] => 1 [degree] => 1 [min] => 1 [max] => 5 [prize] => 一等奖 [v] => 1 )
[1] => Array ( [id] => 2 [degree] => 122 [min] => 97 [max] => 125 [prize] => 二等奖 [v] => 1 ))

但想要的是
$prize_arr = array( <br />array('id'=>1,'degree'=>1,'min'=>1,'max'=>5,'prize'=>'一等奖','v'=>89), <br />array('id'=>2,'degree'=>32,'min'=>7,'max'=>35,'prize'=>'不要灰心','v'=>1));
该怎么办?
------解决方案--------------------
你用var_dump($prize_arr)
------解决方案--------------------
$prize_arr = array( <br />array('id'=>1,'degree'=>1,'min'=>1,'max'=>5,'prize'=>'一等奖','v'=>89), <br />array('id'=>2,'degree'=>32,'min'=>7,'max'=>35,'prize'=>'不要灰心','v'=>1)); 
Copy after login

print_r($prize_arr); 得
Array (
 [0] => Array ( [id] => 1 [degree] => 1 [min] => 1 [max] => 5 [prize] => 一等奖 [v] => 89 )
 [1] => Array ( [id] => 2 [degree] => 32 [min] => 7 [max] => 35 [prize] => 不要灰心 [v] => 1 )

var_export($prize_arr); 得
array (
 0 => array ( 'id' => 1, 'degree' => 1, 'min' => 1, 'max' => 5, 'prize' => '一等奖', 'v' => 89, ),
 1 => array ( 'id' => 2, 'degree' => 32, 'min' => 7, 'max' => 35, 'prize' => '不要灰心', 'v' => 1, ),
)

只不过是显示格式不同而已,并没有改变 $prize_arr 的值

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