从动态主数组创建子数组...基于类似的密钥对

I have a dynamic array.I have shown one instance of that array here.though It is not fixed how many keys are present

Array
(
    [lowest] => 1200
    [highest] => 139900
    [cat_0] => Womens Clothing
    [cat_1] => Smart Phones
    [cat_2] => Mens Clothing
    [cat_3] => Electronics
    [chil_cat_0] => 18
    [chil_cat_1] => 12
    [chil_cat_2] => 7
    [chil_cat_3] => 11
    [chil_cat_4] => 17
    [keyword] => 
)

For this array, I want to create sub array..like.

Array
(
    [cat_0] => Womens Clothing
    [cat_1] => Smart Phones
    [cat_2] => Mens Clothing
    [cat_3] => Electronics
)

Note: Based on similar keys.I have to break my main array to sub array

However, the main array could have any number of similar rows.

Please help me out.

You could use array_filter() to keep only values that match with keys you want :

$out = array_filter($array, function($key){
    // Keep only keys that begins by 'cat_'
    return substr($key, 0, 4) == 'cat_' ; 
    // or
    return preg_match('~^cat_[\d]+~',$key) ; // Use cat_ + number
}, ARRAY_FILTER_USE_KEY);
print_r($out);

Outputs :

Array
(
    [cat_0] => Womens Clothing
    [cat_1] => Smart Phones
    [cat_2] => Mens Clothing
    [cat_3] => Electronics
)