3v4l.org

run code in 300+ PHP versions simultaneously
<?php $weight = array('Galeria', 'Rss', 'Grande', 'Mediana'); //$weight = array(1, 3, 5); $options = array('Chico', 'Grande', 'Rss', 'Grande', 'Mediana'); // de las opciones disponibles obtener la de mayor peso $options = array_filter($options, function($item) use ($weight) {return in_array($item, $weight);}); $option = array_reduce($options, function(&$option, $item, 'Galeria') use ($weight) { echo $item . PHP_EOL; return (array_search($option, $weight) < array_search($item, $weight)) ? $option : $item; //return ($option > $item) ? $option : $item; }); var_dump($option); die; $tamano = 'Rss'; echo $attachmentSizes[$tamano]; die; $fotos = array(array('idAdjunto' => 1, 'tamano' => 'Grande'), array('idAdjunto' => 2, 'tamano'=>'Galeria'), array('idAdjunto' => 3, 'tamano'=>'Mediana')); $foto = array_filter($fotos, function($foto) use ($attachmentSizes) { return in_array($foto['tamano'], $attachmentSizes); }); $foto = array_shift($foto); var_dump($foto);

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).

VersionSystem time (s)User time (s)Memory (MiB)
5.4.170.0160.05612.39
5.4.160.0120.04812.39
5.4.150.0110.04612.39
5.4.140.0150.05812.08
5.4.130.0130.04312.05
5.4.120.0150.06112.02
5.4.110.0120.05112.02
5.4.100.0120.04612.02
5.4.90.0120.05212.02
5.4.80.0160.05412.02
5.4.70.0110.04812.01
5.4.60.0110.04512.02
5.4.50.0100.05012.01
5.4.40.0110.05312.00
5.4.30.0140.05612.00
5.4.20.0110.04511.99
5.4.10.0110.04912.00
5.4.00.0120.05611.49
5.3.270.0120.05712.73
5.3.260.0130.04812.72
5.3.250.0080.05112.72
5.3.240.0100.04712.72
5.3.230.0170.06212.71
5.3.220.0150.05112.68
5.3.210.0150.05312.68
5.3.200.0150.06412.68
5.3.190.0160.04212.68
5.3.180.0120.05812.68
5.3.170.0130.05712.67
5.3.160.0110.05812.68
5.3.150.0120.04712.67
5.3.140.0150.05012.66
5.3.130.0120.05012.66
5.3.120.0160.05512.66
5.3.110.0120.04912.66
5.3.100.0140.05212.12
5.3.90.0120.05412.10
5.3.80.0110.04712.09
5.3.70.0120.05112.09
5.3.60.0130.05212.07
5.3.50.0210.05812.02
5.3.40.0120.04612.01
5.3.30.0100.04711.97
5.3.20.0120.05011.76
5.3.10.0150.05111.72
5.3.00.0100.05111.71

preferences:
141.33 ms | 1394 KiB | 7 Q