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