更新时间:2022-12-09 08:25:42
函数emptyElementExists($ ARR){
返回array_search(,$ ARR)==假的!;
}
示例:
$ VAR =阵列(text1中,,文字3);
后续代码var_dump(emptyElementExists($ VAR));
输出:
布尔(真)
块引用>参考
I have the array $var, and I'd like to return FALSE if one or more element in the array are empty (I mean, the string are "").
I think that
array_filter()
is the better way, but I don't know how to filter it in this manner.How can I do it?
function emptyElementExists()
function emptyElementExists($arr) { return array_search("", $arr) !== false; }
Example:
$var = array( "text1", "", "text3" ); var_dump( emptyElementExists($var) );
Output:
bool(true)
Reference