I am using MYSQLI query to extract data into an array. But when printing the array content, it looks that data is being populated into sub array. This is my code:
<?php
require_once 'database.php';
// Choose the y-axis
$sql = "SELECT `O3` FROM giordan_mod ORDER BY id DESC LIMIT 4";
$resulty = mysqli_query($conn, $sql);
$datay = [];
while($row = mysqli_fetch_array($resulty, MYSQLI_NUM))
{
$datay[] = $row;
}
echo '<pre>'; print_r($datay);'</pre>';
?>
<?php
$test = array(4, 6, 9, 15);
echo '<pre>'; print_r($test);'</pre>';
?>
But when printing the array, the result are as follows:
Array
(
[0] => Array
(
[0] => 40.25
)
[1] => Array
(
[0] => 39.64
)
[2] => Array
(
[0] => 40.13
)
[3] => Array
(
[0] => 40.28
)
)
Array
(
[0] => 4
[1] => 6
[2] => 9
[3] => 15
)
But I would like that MYSQLI query input data into an array and not sub array. That is I need $datay array looks as $test array.