<?php
function italico1(&$arr)
{
if ($cant==0) return null;
$salida = null;
if ($cant>1)
{
for ($i=0;$i<$cant-2;$i++)
$salida .= $arr[$i].' ,';
return $salida.$arr[$cant-2].' y '.$arr[$cant-1];
}else
return $arr[0];
}
function italico2(&$arr)
{
{
case 0: return null;
case 1: return $arr[0];
default:
return implode (' ,',$arr).' y '.$ult; }
}
function alexis($array) {
}
for ($i = 0; $i < 1000; $i++)
alexis($a);
$tiempoAlexis = $fin2 - $ini2;
for ($i = 0; $i < 1000; $i++)
italico1($a);
$tiempoItalico1 = $fin1 - $ini1;
for ($i = 0; $i < 1000; $i++)
italico2($a);
$tiempoItalico2 = $fin1 - $ini1;
echo "Italico (script #1): " . $tiempoItalico1."\n";
echo "Italico (script #2): " . $tiempoItalico2."\n";
echo "Alexis: " . $tiempoAlexis;
PD9waHAKZnVuY3Rpb24gaXRhbGljbzEoJiRhcnIpCiAgICB7CiAgICAgICAgJGNhbnQgPSBjb3VudCgkYXJyKTsgICAgCiAgICAKICAgICAgICBpZiAoJGNhbnQ9PTApICByZXR1cm4gbnVsbDsgICAgICAgIAogICAgICAgICRzYWxpZGEgPSBudWxsOwogICAgICAgIAogICAgICAgIGlmICgkY2FudD4xKQogICAgICAgIHsKICAgICAgICAgICAgZm9yICgkaT0wOyRpPCRjYW50LTI7JGkrKykKICAgICAgICAgICAgICAgICRzYWxpZGEgLj0gJGFyclskaV0uJyAsJzsKICAgICAgICAKICAgICAgICAgICAgcmV0dXJuICRzYWxpZGEuJGFyclskY2FudC0yXS4nIHkgJy4kYXJyWyRjYW50LTFdOyAgCiAgICAgICAgICAgIAogICAgICAgIH1lbHNlCiAgICAgICAgICAgIHJldHVybiAkYXJyWzBdOyAgICAgIAogICAgCiAgICB9CiAKZnVuY3Rpb24gaXRhbGljbzIoJiRhcnIpCnsKICAgIHN3aXRjaCAoY291bnQoJGFycikpCiAgICB7CiAgICBjYXNlIDA6IHJldHVybiBudWxsOwogICAgY2FzZSAxOiByZXR1cm4gJG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