- json_encode: documentation ( source)
<?php
$authorId = array("1", "2");
$authorName = array("Juan Cruz", "Jose Rizal");
$authorSname = array("J. Cruz", "J. Rizal");
$res = [];
foreach($authorId as $key => $value){
$res[] = [
'author_id' => $value,
'author_name' => $authorName[$key],
'author_sname'=> $authorSname[$key]
];
}
echo json_encode($res);