求大神指导一二
程序员文章站
2022-05-27 12:24:40
...
求大神指点一二
数据库连接
看了下 出来的是
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)
------解决方案--------------------
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 的值
数据库连接
$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 的值
相关文章
相关视频
上一篇: 关于PHP5.6.x的新特性