- strpos: documentation ( source)
- microtime: documentation ( source)
- array_fill: documentation ( source)
<?php
$arr = array_fill(0, 1000, 'xxxxx');
$runs = 100;
$first = 0.0;
$second = 0.0;
for ($i = 0; $i < $runs; $i++) {
$start = microtime(true);
foreach ($arr as $value) {
strpos('xxxxxxx', $value);
}
$end = microtime(true);
$first += ($end-$start);
}
print "First: " . ($first/$runs) . PHP_EOL;