3v4l.org

run code in 300+ PHP versions simultaneously
<?php $obj = [ 'this' => 'that', 'and' => 'the', 'other' => (object) [ 'layers' => 'make', 'things' => 'more', 'fun' => (object) [ 'every' => 'time', 'foo' => 'bar', ], ], ]; // Just sort and return the sorted array function array_ksort(array $array) { ksort($array); return $array; } $obj = (object) array_ksort(array_map(function($value) { return !is_object($value) ? $value : (object) array_ksort((array) $value);}, $obj)); var_dump($obj);

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
153.24 ms | 2205 KiB | 15 Q