Dear Internals,
I'd like a white bikeshed, but until you can decide on a color, how
about we just build the bikeshed already. Please consider the following
specification:
========== 8< ==================== 8< ==================== 8< ==========
filled
(PHP 5.2.0)
filled - Find first non-empty value in a variable list where empty()
evaluates as FALSE.
Description
------------------------------
mixed filled ( mixed varname [, mixed ...] )
filled() takes a variable number of parameters. For each of these,
*filled()* looks for a variable where !empty( varname ) evaluates as
TRUE. It returns the first non-empty value or NULL if all values are
empty().
Note: filled() only checks variables as anything else will result in a
parse error. In other words, the following will not work:
filled(trim($name)).
filled() is the opposite of empty(), and no warning is generated
when any one of the variables is not set.
Return Values
------------------------------
Returns first non-empty() value.
If all values are empty(), returns NULL.
Example
------------------------------
<?php
echo filled($x["somekey"], $_GET["getkey"], $default, "example");
echo filled("yes"); // prints yes
filled(false); // returns NULL
echo filled($x["apple"], $y, "banana"); // prints banana
$y = "cat";
echo filled($x["apple"], $y, "banana"); // prints cat
$x["apple"] = "pear";
echo filled($x["apple"], $y, "banana"); // prints pear
unset($x["apple"]);
echo filled($x["apple"], $y, "banana"); // prints cat
?>
See also empty()
========== 8< ==================== 8< ==================== 8< ==========
Dante
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php