我想将$ pair推送到现有阵列但不行...... 我已经使用了合并数组而且没有用。
$pair = array(
'status' => 1
);
$numberof = mysqli_num_rows($result);
if($numberof > 0)
{
// output data of each row
while($row[] = $result->fetch_assoc()) {
$tem = $row;
$tem = $row['status'] = '1';
$json = json_encode($tem);
这是最终结果:
{"0":{"id":"7","nome":"dfsdfsdfsdff","email":"and@gmail.com"},"status":1}
我只想要最终结果:
{"id":"7","nome":"dfsdfsdfsdff","email":"and@gmail.com","status":1}
答案 0 :(得分:0)
$ TEM =阵列(); $温度= array_merge($ TEM,$对);
然后编码$ temp
答案 1 :(得分:0)
你在while循环中使用了数组。拜托,希望你能得到答案
$pair = array(
'status' => 1
);
$numberof = mysqli_num_rows($result);
if($numberof > 0)
{
// output data of each row
while($row = $result->fetch_assoc()) { // instead $row[] use only $row
$row['status'] = '1';
$json = json_encode($row);
答案 2 :(得分:0)
你试过while($row = $result->fetch_assoc()) { ... }
代替
while($row[] = $result->fetch_assoc()) { ... }
?
答案 3 :(得分:0)
$pair = array( 'status' => 1);
$numberof = mysqli_num_rows($result);
if($numberof > 0) {
while($row[] = $result->fetch_assoc()) {
$row['status'] = '1';
}
$json = json_encode($row);
}