@ 2015-12-10T12:49:42Z <?php
const VLANS = [
'default' => [
'prefix' => '',
],
'iutsb_rech' => [
'prefix' => '129.20.',
],
'iutsb_etu' => [
'prefix' => '148.60.',
]
];
const SHORT_VLANS = [
'e' => 'iutsb_etu',
'r' => 'iutsb_rech',
];
function a($hostname) {
$vlanShort = substr($hostname, 1, 1);
if (!array_key_exists($vlanShort, self::SHORT_VLANS)) {
return false;
}
$prefix = self::VLANS[self::SHORT_VLANS[$vlanShort]]['prefix'];
$prefixLength = substr_count($prefix, '.');
$hostnameLength = strlen($hostname);
$ip = [];
for ($i = $prefixLength; $i < 4; $i++) {
$ip[] = intval(substr($hostname, $hostnameLength + (($i - 4) * 3), 3));
}
return $prefix . implode('.', $ip);
}
echo a('me212128');
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 7.0.0 0.003 0.043 20.14 5.6.16 0.020 0.070 20.72 5.6.15 0.000 0.057 18.20 5.6.14 0.007 0.080 18.19 5.6.13 0.013 0.077 18.28 5.6.12 0.007 0.043 21.13 5.6.11 0.013 0.077 21.02 5.6.10 0.007 0.040 20.99 5.6.9 0.017 0.073 21.11 5.6.8 0.000 0.043 20.41 5.5.30 0.007 0.067 18.02 5.5.29 0.013 0.077 17.95 5.5.28 0.003 0.063 20.96 5.5.27 0.003 0.060 20.75 5.5.26 0.010 0.043 20.79 5.5.25 0.003 0.083 20.54 5.5.24 0.023 0.063 20.19
preferences:dark mode live preview
138.92 ms | 1394 KiB | 7 Q