3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $json1 = '{"data": [{"category": "Games","id": "45345"}, {"category": "Music","id": "345345345"}, {"category": "Food","id": "1"}, {"category": "Pets","id": "13245345"}],"paging": {"next": "https://graph.facebook.com/1161990140/likes?limit=2&offset=2&__after_id=118243704898877"}}'; $json2 = '{"data": {"something": "blah","posts": [{"id": "34241","title": "orange"}],"items": [{"id": "1","name": "orange"},{"id": "2","name": "dog"},{"id": "3","name": "cat"},{"id": "4","name": "apple"}]}}'; $array1 = json_decode($json1, true); $array2 = json_decode($json2, true); $ids = array_map(function($value) { return $value['id']; }, $array2['data']['items']); $new = array_filter($array1['data'], function($var) use ($ids) { return !in_array($var['id'], $ids); }); var_dump($new);
Output for 5.3.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
array(3) { [0]=> array(2) { ["category"]=> string(5) "Games" ["id"]=> string(5) "45345" } [1]=> array(2) { ["category"]=> string(5) "Music" ["id"]=> string(9) "345345345" } [3]=> array(2) { ["category"]=> string(4) "Pets" ["id"]=> string(8) "13245345" } }
Output for hhvm-3.10.0

Process exited with code 153.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/j38AC on line 8
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION, expecting ')' in /in/j38AC on line 8
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/j38AC on line 8
Process exited with code 255.