3v4l.org

run code in 300+ PHP versions simultaneously
<?php $country_ids = range(1,5); $result['fields'][0]['field_type'] = "countries"; foreach ($country_ids as $id) { $result['fields'][0]['field_value'][] = ["country_id" => $id, "match_type" => "exact"]; } var_export($result); echo "\n---\n"; echo json_encode($result, JSON_PRETTY_PRINT); // this resembles your posted data
Output for git.master, git.master_jit, rfc.property-hooks
array ( 'fields' => array ( 0 => array ( 'field_type' => 'countries', 'field_value' => array ( 0 => array ( 'country_id' => 1, 'match_type' => 'exact', ), 1 => array ( 'country_id' => 2, 'match_type' => 'exact', ), 2 => array ( 'country_id' => 3, 'match_type' => 'exact', ), 3 => array ( 'country_id' => 4, 'match_type' => 'exact', ), 4 => array ( 'country_id' => 5, 'match_type' => 'exact', ), ), ), ), ) --- { "fields": [ { "field_type": "countries", "field_value": [ { "country_id": 1, "match_type": "exact" }, { "country_id": 2, "match_type": "exact" }, { "country_id": 3, "match_type": "exact" }, { "country_id": 4, "match_type": "exact" }, { "country_id": 5, "match_type": "exact" } ] } ] }

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:
26.83 ms | 404 KiB | 8 Q