php返回空数组

Here the problems:

The line: echo($arr) prints "arrayarrayarray...." on the screen (I added this line only to see what's inside $arr).

The encode command prints nothing. But last week was working!!

Please, help! Thanks in advance.

$query="select nome, categoria, produttore, descrizione,prezzoquantita,unitaquantita, prezzopezzi, informazioni, foto, flagpezzi, unitamisura from prodotti;";
$result = $mysqli->query($query) or die($mysqli->error.__LINE__);
$arr = array();
if($result->num_rows > 0) {
    while($row = $result->fetch_assoc()) {
        $arr[] = $row;
        echo ($arr);
    }
}

print (json_encode($arr, true));