3v4l.org

run code in 300+ PHP versions simultaneously
<?php $find = "city"; $re = '/(' . $find . ')\":\s\"(.*?)\"|\"(\w+)\":\s\"(' . $find . ')/m'; $str = '{ "company": { "id": "123456", "name": "Test Company LLC.", "FEIN": "22-2222222", "address": { "address_line_1": { "street": "1 Street St, Suite 12", "city": "San Francisco", "postalCode": "123456" }, "address_line_2": { "state": "CA", "country": "USA" } }, "phone": "1-800-XXX-XXXX", "fax": "1-800-XXX-XXXX", "email": "admin@abc.com", "URL": "www.abc.com" }, "producer": { "id": "LLXXXX", "name": "Test Name", "phone": "555-555-5555", "mobile": "555-555-5555", "fax": "555-555-5555", "email": "test@abc.com", "producerSubCode": "111", "NIPRId": "123456", "stateProducerId": "12344" } }'; preg_match_all($re, $str, $matches); $result["value-match"] = array_slice(array_column($matches, 0),1,2); $result["key-match"] = array_slice(array_column($matches, 0),3,2); var_dump($result);
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { ["value-match"]=> array(2) { [0]=> string(4) "city" [1]=> string(13) "San Francisco" } ["key-match"]=> array(2) { [0]=> string(0) "" [1]=> string(0) "" } }

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:
61.21 ms | 401 KiB | 8 Q