- substr: documentation ( source)
- var_dump: documentation ( source)
- strpos: documentation ( source)
- microtime: documentation ( source)
- implode: documentation ( source)
- array_keys: documentation ( source)
<?php
$time = microtime(true);
for ($i = 0; $i < 10000; $i++) {
$array = array();
$str = '|' . implode('|', array_keys($_SERVER));
do {
if (false !== $pos = strpos($str, '|SCRIPT_')) {
if (false !== $pos2 = strpos($str, '|', $pos + 1)) {
$array[] = substr($str, $pos + 1, $pos2 - $pos - 1);
$str = substr($str, $pos2);
}
else {
$array[] = substr($str, $pos + 1);
$str = '';
}
}
} while ($pos !== false && $str);
}
var_dump($array, microtime(true) - $time);