3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Element { /** * Checks if the key is a property. * * @param string $key * The key to check. * * @return bool * TRUE of the key is a property, FALSE otherwise. */ public static function property($key) { return is_string($key) && $key[0] == '#'; } /** * Gets properties of a structured array element (keys beginning with '#'). * * @param array $element * An element array to return properties for. * * @return array * An array of property keys for the element. */ public static function properties(array $element) { return array_filter(array_keys($element), 'static::property'); } } $element = [ '#property1' => 'property1', '#property2' => 'property2', 'property3' => 'property3', 0 => [], ]; $properties = Element::properties($element); var_dump($properties);
Output for rfc.property-hooks, git.master_jit, git.master
Deprecated: Use of "static" in callables is deprecated in /in/fn61K on line 28 array(2) { [0]=> string(10) "#property1" [1]=> string(10) "#property2" }

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:
56.68 ms | 2722 KiB | 4 Q