i have a while loop from which im fetching post id and adding them to array like shown below
$tobi = array();
while($result = mysqli_fetch_array($msql)){
$imp = $result['msg_id']; // these id are like 316 etc
array_push($tobi, $imp);
}
print_r($tobi);
but when i printed the array it resulted
Array ( [0] => 316 ) Array ( [0] => 315 )
why the array has created another element? i want the array to be like
Array ( [0] => 316 [1] => 315 )
i tried using $tobi[] = $imp; also but same result got
after doing print_r($result);
Array ( [0] => 318 [msg_id] => 318 ) Array ( [0] => 318 ) Array ( [0] => 317 [msg_id] => 317 ) Array ( [0] => 317 )
after doing print_r($msql);
mysqli_result Object ( [current_field] => 0 [field_count] => 1 [lengths] => [num_rows] => 2 [type] => 0 ) Array ( [0] => 318 ) Array ( [0] => 317 )
$tobi = array();Every iteration a fresh array!