Field::get( string $key, mixed $default = null, array $array = null )
Description #
Get a value from a path or default value if the path doesn’t exist
Parameters #
- $keystring (Required) Path.
- $defaultmixed (Optional) Default value. Default value: null
- $arrayarray (Optional) Array to search. Default value: null
Source #
File: lib/form/class-field.php
public function get( $key, $default = null, $array = null ) { $keys = explode( '.', (string) $key ); if ( null === $array ) { $array = &$this->args; } foreach ( $keys as $key ) { if ( ! is_array( $array ) || ! array_key_exists( $key, $array ) ) { return $default; } $array = &$array[ $key ]; } return $array; }
Expand full source code Collapse full source code View on GitHub: lib/form/class-field.php:227
Add your comment