3v4l.org

run code in 300+ PHP versions simultaneously
<?php $scan = "00:12:a9:54:f6:a7,Privacy,-52.00,3Com,6,30:91:8f:24:07:d0,RSN: Privacy,-85.00,CenturyLink3873,1,00:0c:e5:46:2d:74,ShortSlotTime,-92.00,WLAN,1,c0:3f:0e:57:87:e8,RSN: Privacy,-94.00,Megan-PC-Wireless,6,00:12:a9:54:f6:a7,ShortPreamble,-45.00,WLAN,7"; $escan = (explode(",",$scan)); $cscan = (array_chunk($escan, 5)); class Util { static function arrayToObject($array, $class = 'stdClass', $strict = false) { if (!is_array($array)) { return $array; } //create an instance of an class without calling class's constructor $object = unserialize( sprintf( 'O:%d:"%s":0:{}', strlen($class), $class ) ); if (is_array($array) && count($array) > 0) { foreach ($array as $name => $value) { $name = strtolower(trim($name)); var_dump($name); if (!empty($name)) { if(method_exists($object, 'set'.$name)){ $object->{'set'.$name}(Util::arrayToObject($value)); }else{ if(($strict)){ if(property_exists($class, $name)){ $object->$name = Util::arrayToObject($value); } }else{ $object->$name = Util::arrayToObject($value); } } } } return $object; } else { return FALSE; } } } $device = arrayToObject($cscan); var_dump($device); ?>
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Call to undefined function arrayToObject() in /in/o4ScN:54 Stack trace: #0 {main} thrown in /in/o4ScN on line 54
Process exited with code 255.

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