我的关联数组是使用函数填充的。它的第一个元素键是空白的,我需要它是0.
$blocks= get_data_ordered('blocks', 'page_id', $page, '', 'sequence');
highlight_string("<?php\n\$blocks =\n" . var_export($blocks, true) . ";\n?>");
function get_data_ordered($table, $condition_field, $condition_value, $limit, $order) {
include 'conf/config.php';
include 'conf/opendb.php';
if (!$condition_field){
$condition = "";
}
else{
$condition = "WHERE `$condition_field`='$condition_value'";
}
if($limit){
$limit_query="LIMIT $limit";
$i=0;
}
$result=mysqli_query($conn, "SELECT * FROM $table $condition ORDER BY $order ASC $limit_query");
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC))
{
if($limit==1){
return $row;
}
else{
$output[$i] = $row;
$i++;
}
}
return $output;
include 'conf/closedb.php';
}
我目前的输出如下。第一个元素键是空白而不是 0
$blocks =
array (
'' =>
array (
'id' => '2',
),
1 =>
array (
'id' => '6',
)
);
我需要的是从 0 开始而不是空白键
$blocks =
array (
0 =>
array (
'id' => '2',
),
1 =>
array (
'id' => '6',
)
);
请帮我解决这个问题
眼眸繁星
MMMHUHU