<?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.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
- array (
'== null' =>
array (
0 => 0,
1 => '',
2 => NULL,
3 => false,
4 => 0.0,
),
'!= null' =>
array (
0 => ' ',
1 => '0',
),
)
preferences:
52.3 ms | 406 KiB | 5 Q