<?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);
preferences:
24.68 ms | 406 KiB | 5 Q