当前位置:Gxlcms > PHP教程 > 求大神指导一二

求大神指导一二

时间:2021-07-01 10:21:17 帮助过:5人阅读

求大神指点一二
数据库连接
$rs = mysql_query("select id,degree,min,max,prize,v from magic_config");
while($r = mysql_fetch_assoc($rs)) {
$prize_arr[] = $r;
}
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(
array('id'=>1,'degree'=>1,'min'=>1,'max'=>5,'prize'=>'一等奖','v'=>89),
array('id'=>2,'degree'=>32,'min'=>7,'max'=>35,'prize'=>'不要灰心','v'=>1));
该怎么办?
------解决方案--------------------
你用var_dump($prize_arr)
------解决方案--------------------
$prize_arr = array( 
array('id'=>1,'degree'=>1,'min'=>1,'max'=>5,'prize'=>'一等奖','v'=>89),
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 的值

人气教程排行