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
Name | Type | Required | Default | Description |
---|---|---|---|---|
$needle | string | true | - | Name of the searched key. |
$haystack | string | false | false | Associative array. If false, $_GET is set to be the $haystack. |
$default | mixed | false | null | Value 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;
}