根据值从数组中删除值?

iam*_*rus 1 php

我有一个PHP数组,其父级称为"项目".在该数组中,我想删除所有不包含字符串的值(我将使用正则表达式来查找).我该怎么做?

Nad*_*adh 5

foreach($array['items'] as $key=>$value) { // loop through the array
    if( !preg_match("/your_regex/", $value) ) {
        unset($array['items'][$key]);
    }
}
Run Code Online (Sandbox Code Playgroud)