Ds \ Collection::isEmpty()函数是PHP中的内置函数,用于返回collection是否为空。
用法:
Ds\Collection::isEmpty ( void ):bool
参数:该函数不接受任何参数。
返回值:如果collection为空,则返回True,否则返回False。
以下示例程序旨在说明PHP中的Ds \ Collection::isEmpty()函数:
范例1:
// Create a collection
$collection = new \Ds\Vector([10, 15, 21, 13, 16, 18]);
// Use isEmpty function
$res = $collection->isEmpty();
// Display the result
var_dump($res);
// Create a collection
$collection = new \Ds\Vector();
// Use isEmpty function
$res = $collection->isEmpty();
// Display the result
var_dump($res);
?>
输出:
bool(false)
bool(true)
范例2:
// Create a collection
$collection = new \Ds\Vector();
// display output
var_dump($collection->isEmpty());
// Create a collection
$collection = new \Ds\Vector([1, 3, 5, 2, 6]);
// Display output
var_dump($collection->isEmpty());
?>
输出:
bool(true)
bool(false)