求大神指点一二
数据库连接
$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);
登入後複製
看了下 出来的是
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));
登入後複製
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 的值