3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ObjContainer { } class Array2Obj { public function isArrayAssociative(array $array) { return (bool) count(array_filter(array_keys($array), 'is_string')); } public function __CONSTRUCT(array $array) { if(isArrayAssociative($array)) { $obj = new ObjContainer; foreach($array as $key => $val) { if(is_array($val)) { $obj->{$key} = new Array2Obj($val); } else { $obj->{$key} = $val; } } return $obj; } else { $array = array(); foreach($array as $val) { if(is_array($val)) { $array[] = new Array2Obj($val); } else { $array[] = $val; } } return $array; } } } $array = ["database"=>["host"=>"localhost","dbname"=>"mydb","user"=>"root","password"=>""]]; $xml = new Array2Obj($array);
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Call to undefined function isArrayAssociative() in /in/FPHKM:8 Stack trace: #0 /in/FPHKM(35): Array2Obj->__CONSTRUCT(Array) #1 {main} thrown in /in/FPHKM on line 8
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:
42.03 ms | 401 KiB | 8 Q