<?php $foo = [ '50/2021-10-31@2', '93/2021-11-14@2', '300/2022-02-14@2', ]; $bar = '2021-11-14'; $getTransitos = fn($test, $values): ?int => array_reduce( $values, fn($found, $value): ?int => $found ?? ( strpos($value, $test) ? sscanf($value, '%d/')[0] : null ), null ); var_dump($getTransitos($bar, $foo));
You have javascript disabled. You will not be able to edit any code.