3v4l.org

run code in 300+ PHP versions simultaneously
<?php $fullArtistTimes = [ ['time' => '18:31:00', 'artist' => 'LUIS RODRIGUEZ & DEN HARROW'], ['time' => '18:32:00', 'artist' => 'J BALVIN'], ['time' => '18:33:00', 'artist' => 'THE BLACK EYED PEAS FT J BALVIN'], ['time' => '18:34:00', 'artist' => 'THE BLACK EYED PEAS FT J BALVIN'], ['time' => '18:35:00', 'artist' => 'J BALVIN'] ]; $fullArtist = 'THE BLACK EYED PEAS FT J BALVIN'; $artistDelimiters = '~ (?:[+e,&]|and|f(?:ea)?t\.?|vs\.?) ~i'; $artists = array_flip(preg_split($artistDelimiters, $fullArtist)); $result = []; foreach ($fullArtistTimes as $row) { foreach (preg_split($artistDelimiters, $row['artist']) as $artist) { if (isset($artists[$artist])) { $result[] = "{$artist} is at {$row['time']}"; } } } var_export($result);
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
array ( 0 => 'J BALVIN is at 18:32:00', 1 => 'THE BLACK EYED PEAS is at 18:33:00', 2 => 'J BALVIN is at 18:33:00', 3 => 'THE BLACK EYED PEAS is at 18:34:00', 4 => 'J BALVIN is at 18:34:00', 5 => 'J BALVIN is at 18:35:00', )

preferences:
135.91 ms | 408 KiB | 5 Q