Form::get( string $key, mixed $default_value = null, array $arr = null )

Description #

Get a value from a path or default value if the path doesn’t exist

Parameters #

  • $key
    string (Required) Path.
  • $default_value
    mixed (Optional) Default value. Default value: null
  • $arr
    array (Optional) Array to search. Default value: null

Source #

File: lib/class-form.php

	public function get( $key, $default_value = null, $arr = null ) {
		$keys = explode( '.', (string) $key );

		if ( null === $arr ) {
			$arr = &$this->args;
		}

		foreach ( $keys as $key ) {
			if ( ! array_key_exists( $key, $arr ) ) {
				return $default_value;
			}

			$arr = &$arr[ $key ];
		}

		return $arr;
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment