<?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);
You have javascript disabled. You will not be able to edit any code.