具有多文本值的搜索数组



在这个数组中,我想从值中找到单词"in",并从歌曲中创建新的数组,包括专辑中的数字(关键(歌曲。

$londonCalling = array(
'song-01' => 'London Calling',
'song-02' => 'Brand New Cadillac',
'song-03' => 'Jimmy Jazz',
'song-04' => 'Hateful',
'song-05' => 'Rudie Cant Fail',
'song-06' => 'Spanish Bombs',
'song-07' => 'The Right Profile',
'song-08' => 'Lost in the Supermarket',
'song-09' => 'Clampdown',
'song-10' => 'The Guns of Brixton',
'song-11' => 'Wrong Em Boyo',
'song-12' => 'Death or Glory',
'song-13' => 'Koka Kola',
'song-14' => 'The Card Cheat',
'song-15' => 'Lovers Rock',
'song-16' => 'Four Horsemen',
'song-17' => 'Im Not Down',
'song-18' => 'Revolution Rock',
'song-19' => 'Train in Vain');

这可以用preg_greponeliner:完成

print_r(preg_grep('/in/', $londonCalling));

交替排列过滤器

$res = array_filter($londonCalling , function($e){
return strpos($e, 'in') !== false;
});
print_r([$res]);

相关内容

  • 没有找到相关文章