3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php if (interface_exists('JsonSerializable', true) === false) { interface JsonSerializable { /** * (PHP 5 &gt;= 5.4.0)<br/> * Specify data which should be serialized to JSON * @link http://php.net/manual/en/jsonserializable.jsonserialize.php * @return mixed data which can be serialized by <b>json_encode</b>, * which is a value of any type other than a resource. */ function jsonSerialize (); } } /** * @package MXO_JSON */ abstract class MXO_JSON_Collection implements Countable, ArrayAccess, IteratorAggregate, JsonSerializable { protected $container = array(); public function __construct(array $init_array = array()) { $this->container = $init_array; } public function count() { return count($this->container); } public function offsetExists($offset) { return isset($this->container[$offset]); } public function offsetGet($offset) { return isset($this->container[$offset]) === true ? $this->container[$offset] : null; } public function getIterator() { return new ArrayIterator($this->container); } public function __clone() { $this->container = MXO_JSON::copy($this->container); } /** * returns result in raw format - for use with php's array functions * * @deprecated If you need this, consider adding more array-specific functions to MXO_JSON_Utils */ public function getRaw() { $result = array(); foreach ($this->container as $key => $element) { if ($element instanceof MXO_JSON_Collection) { $result[$key] = $element->getRaw(); } else { $result[$key] = $element; } } return $result; } /** * Like getRaw, but only converts this collection to an array; * deeper collections are left as-is. * * @deprecated If you need this, consider adding more array-specific functions to MXO_JSON_Utils */ public function getAsArray() { return $this->container; } public function keyExists($key) { return array_key_exists($key, $this->container); } public function keys() { return array_keys($this->container); } public function values() { return array_values($this->container); } public function sort($sort_flags = null) { return sort($this->container, $sort_flags); } public function rsort($sort_flags = null) { return rsort($this->container, $sort_flags); } abstract public function natsort(); abstract public function natcasesort(); public function usort($value_compare_func) { return usort($this->container, $value_compare_func); } abstract public function map($callback); abstract public function filter($callback); abstract public function merge($obj); public function search($needle) { return array_search($needle, $this->container, true); } abstract public function intersect($obj); }
Output for 5.1.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/F7pSJ on line 22
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING in /in/F7pSJ on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING in /in/F7pSJ on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/F7pSJ on line 4
Process exited with code 255.