#5742 - Consider in_array when there are 3 or more string comparisons
0 guests and 0 members have recently viewed this.
The top 3 point earners from 30th Nov 2025 to 7th Dec 2025.
| Gabri |
|
|
|---|---|---|
| PDStig |
|
|
| Adam Edington |
|
|
There are no events at this time
<?php
define('ITERATIONS', 10000000);
$x = 'hello';
$a = microtime(true);
for ($i = 0; $i < ITERATIONS; $i++) {
if ($x == 'a' || $x == 'b' || $x == 'c') {
}
}
$b = microtime(true);
var_dump($b - $a);
$a = microtime(true);
for ($i = 0; $i < ITERATIONS; $i++) {
if (in_array($x, ['a', 'b', 'c'])) {
}
}
$b = microtime(true);
var_dump($b - $a);
float(0.28515386581421)
float(0.10288000106812)