3v4l.org

run code in 300+ PHP versions simultaneously
<?php $fruit = array(); $fruit[] = array('id' => 1, 'name' => 'Banana 1', 'pieces' => get_pieces(1)); $fruit[] = array('id' => 1, 'name' => 'Pear 1', 'pieces' => get_pieces(1)); $fruit[] = array('id' => 1, 'name' => 'Mango 1', 'pieces' => get_pieces(1)); $fruit[] = array('id' => 2, 'name' => 'Banana 2', 'pieces' => get_pieces(2)); $fruit[] = array('id' => 2, 'name' => 'Pear 2', 'pieces' => get_pieces(2)); $fruit[] = array('id' => 2, 'name' => 'Mango 2', 'pieces' => get_pieces(2)); function get_pieces($id) { $pieces = array(); switch ($id) { case 1: $pieces[] = array('number' => 1); $pieces[] = array('number' => 2); break; case 2: $pieces[] = array('number' => 3); $pieces[] = array('number' => 4, 'qwerty' => 1); break; } return $pieces; } print json_encode(array('fruit' => $fruit));
Output for git.master, git.master_jit, rfc.property-hooks
{"fruit":[{"id":1,"name":"Banana 1","pieces":[{"number":1},{"number":2}]},{"id":1,"name":"Pear 1","pieces":[{"number":1},{"number":2}]},{"id":1,"name":"Mango 1","pieces":[{"number":1},{"number":2}]},{"id":2,"name":"Banana 2","pieces":[{"number":3},{"number":4,"qwerty":1}]},{"id":2,"name":"Pear 2","pieces":[{"number":3},{"number":4,"qwerty":1}]},{"id":2,"name":"Mango 2","pieces":[{"number":3},{"number":4,"qwerty":1}]}]}

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
27.96 ms | 406 KiB | 5 Q