<?php
$result = [];
foreach ([0, '', null, false, ' ', '0', .0] as $v) {
$k = match(true) {
$v != null => '!= null',
$v == null => '== null',
// This should never occur.
default => '?',
};
$result[$k][] = $v;
}
var_export($result);
- Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.14, 8.4.1
- array (
'== null' =>
array (
0 => 0,
1 => '',
2 => NULL,
3 => false,
4 => 0.0,
),
'!= null' =>
array (
0 => ' ',
1 => '0',
),
)
preferences:
68.91 ms | 406 KiB | 5 Q