3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $desc = '{"a":1, "b":2}'; $ob = '{"a":1, "b":2, "c":3}'; function isLikeThis(string $description, string $tested) { $args = func_get_args(); $assocArrayArgs = array_map(function($arg){ get_object_vars(json_decode($arg)); }, $args ); var_dump($args); return !(bool)call_user_func_array('array_diff_assoc', $args); } var_dump(isLikeThis($desc, $ob));
based on Zc8eX
Output for 7.3.0rc3
array(2) { [0]=> string(14) "{"a":1, "b":2}" [1]=> string(21) "{"a":1, "b":2, "c":3}" } Warning: array_diff_assoc(): Expected parameter 1 to be an array, string given in /in/6i6Yg on line 13 bool(true)
Output for 7.0.0 - 7.3.0beta1
array(2) { [0]=> string(14) "{"a":1, "b":2}" [1]=> string(21) "{"a":1, "b":2, "c":3}" } Warning: array_diff_assoc(): Argument #1 is not an array in /in/6i6Yg on line 13 bool(true)
Output for 5.6.0 - 5.6.25
Catchable fatal error: Argument 1 passed to isLikeThis() must be an instance of string, string given, called in /in/6i6Yg on line 15 and defined in /in/6i6Yg on line 5
Process exited with code 255.