$result = mysqli_query($con, "SELECT * FROM users");
$usersArray=[];
tableArrayPushData($result, $usersArray);
function tableArrayPushData($result, $tableArray){
    while ($row = $result->fetch_assoc()) {
        $str = '';
        foreach ($row as $value) {
            $str = $str.$value.'|';
        }
        $newStr = rtrim($str, "| ");
        array_push($tableArray,$newStr);
    }
}
for ($i=0; $i<count($usersArray); $i++){//array is always empty at this point
    echo "Ok";
    echo "<br>";
}
I don't understand why, but usersArray is empty despite the fact that I added data there.
The MySQL table has rows with data, so it can't be empty.
 
    