3v4l.org

run code in 300+ PHP versions simultaneously
<?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);

preferences:
27.36 ms | 404 KiB | 5 Q