<?php $inputArray = array('first-key' => 'first value', 'second-key' => 'second value', array('foo-1' => 'val', 'bar'=> 'value', 'foo-2' => 'val2'), array('soup' => 'carrots', 'fruit' => 'banana') ); $outputArray = array_filter( $inputArray, function ($element) { return ! is_array($element) || ! empty( array_filter($element, function($key) { return strpos($key, 'foo-') === 0; }, ARRAY_FILTER_USE_KEY) ); } ); var_dump($outputArray);
You have javascript disabled. You will not be able to edit any code.