beans_get

Get value from $_GET or defined $haystack.

beans_get( string $needle, string $haystack = false, mixed $default = null )

Return: (string) Value if found, $default otherwise.

Parameters

NameTypeRequiredDefaultDescription
$needlestringtrue-Name of the searched key.
$haystackstringfalsefalseAssociative array. If false, $_GET is set to be the $haystack.
$defaultmixedfalsenullValue returned if the searched key isn't found.

Source

function beans_get( $needle, $haystack = false, $default = null ) {

	if ( false === $haystack ) {
		$haystack = $_GET;
	}

	$haystack = (array) $haystack;

	if ( isset( $haystack[ $needle ] ) ) {
		return $haystack[ $needle ];
	}

	return $default;

}