fetch data primary key value as the index for the associative array

前端 未结 2 941
别跟我提以往
别跟我提以往 2021-01-20 04:17

After executing a fetch query I get a result array:

[row_choice] => Array
  (
    [0] => Array
      (
        [id] => 277410
        [text_value] =         


        
2条回答
  •  失恋的感觉
    2021-01-20 04:58

    You should create a new array variable as below.

    $recArr = array();
    
    while ($records = mysqli_fetch_array($query)) {
        $recArr[$records['id']] = $records;
    }
    
    var_dump($recArr);
    

    Good luck.

提交回复
热议问题