3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $data = array( 'ua' => array( 'family', 'major' ), 'os' => array( 'family', 'major' ) ); $result = new StdClass(); $result->ua = new StdClass(); $result->ua->family = "Safari"; $result->ua->major = "6"; $result->ua->minor = "0"; $result->ua->patch = "2"; $result->os = new StdClass(); $result->os->family = "Mac OS X"; $result->os->major = "10"; $result->os->minor = "7"; $result->os->patch = "5"; $result->os->patchMinor = "[null]"; $result->os->patchMinor = function (){ return 'qsdf'}; $ret = array(); foreach ( $data as $object => $values ) { $ret[$object] = array_intersect_key( (array) $result->$object, array_flip( $values ) ); } var_dump($ret);
Output for 5.3.0 - 5.4.26
Parse error: syntax error, unexpected '}' in /in/frfOB on line 19
Process exited with code 255.