I have use this code to make json
object
if(mysql_num_rows($result)) {
while($document = mysql_fetch_assoc($result)) {
$documents[] = $document;
}
}
header('Content-type: application/json');
echo json_encode(array('documents'=>$documents));
It gives me single json in document like this
{"document":[{"document":{"id":"2","name":"test","pages":"name","img":"path","lines":"data"}]}
But i need
{"document":[{"document":{"id":"2","name":"test",pages":[{"img":"first img","lines":" <p>first line"}],pages":[{"img":"second img","lines":" <p>second line"}]}]}
Means in existing json need another json name pages which contain further img and lines. How it can do?