<?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) use ($weight) {
// return (array_search($option, $weight) < array_search($item, $weight)) ? $option : $item;
// }, 'Mediana');
$fotos = array(array('idAdjunto' => 1, 'tamano' => 'Grande'),
array('idAdjunto' => 2, 'tamano'=> 'Galeria'),
array('idAdjunto' => 3, 'tamano'=> 'Mediana'));
$fotos = array_filter($fotos, function($foto) use ($weight) {return in_array($foto['tamano'], $weight);});
$foto = array_reduce($fotos, function(&$foto, $item) use ($weight) {
return (array_search($foto['tamano'], $weight) < array_search($item['tamano'], $weight)) ? $foto : $item;
}, $fotos[0]);
var_dump($foto);
preferences:
36.22 ms | 402 KiB | 5 Q