Create a JSONArray using a while loop in PHP
<p>I will be sending the array to java in order to populate a ListView,  how do I get the following code to output an array?:</p>

<pre><code>&lt;?php

$user = 'root';
$pass = '';
$db = 'uopuser';

$con=mysqli_connect('localhost', $user, $pass, $db) or die('Unable to connect');


$statement = mysqli_prepare($con, 'SELECT * FROM society');
mysqli_stmt_execute($statement);

mysqli_stmt_store_result($statement);
mysqli_stmt_bind_result($statement, $society_id, $name, $email, $description);

$society = array();

while(mysqli_stmt_fetch($statement)){
    $society['society_id'] = $society_id;
    $society['name'] = $name;
    $society['email'] = $email;
    $society['description'] = $description;
    echo json_encode($society);
}

echo json_encode($society);

mysqli_stmt_close($statement);

mysqli_close($con);

?&gt;
</code></pre>

<p>Rather than:</p>

<pre><code>{"society_id":1,"name":"TestName1","email":"Test@email1","description":"TestDes1"}
{"society_id":2,"name":"TestName2","email":"Test@email2","description":"TestDes2"}
{"society_id":3,"name":"TestName3","email":"Test@email3","description":"TestDes3"}
</code></pre>

<p>I've looked about the internet before posting this but am seriously confused! Thanks to anyone in advance.</p>