Well, you could do it using preg_grep()
:
$output = preg_grep('!^car_!', $array);
You could use array_filter()
too but you have to pass a test function into that.
More Related Contents:
- Filter array by its keys using an array of allowed keys
- Remove all elements from array that do not start with a certain string
- Get difference between associative rows of two 2-dimensional arrays
- Recursively remove empty elements and subarrays from a multi-dimensional array
- How to filter an associative array comparing keys with values in an indexed array?
- Explode string into array with no empty elements?
- Add a prefix to each item of a PHP array
- Checking if ANY of an array’s elements are in another array
- Return only duplicated entries from an array (case-insensitive)
- Most efficient way to search for object in an array by a specific property’s value
- array_diff to compare two associative arrays
- PHP Foreach returns separated(individual) arrays
- Sorting an associative array in PHP [duplicate]
- Return single column from a multi-dimensional array
- Merge two arrays as key value pairs in PHP
- Convert backslash-delimited string into an associative array
- Group array by subarray values
- php – How do I fix this illegal offset type error
- PHP array_filter with arguments
- Unexpected bracket ‘[‘ – PHP [duplicate]
- scandir() to sort by date modified
- Print the keys of an array
- Sort Object in PHP
- PHP – Get key name of array value
- Group array values based on key in php? [duplicate]
- How to search through a JSON Array in PHP
- How can I sum all values of a specific array key recursively?
- CMS Routing in MVC
- Best way to initialize (empty) array in PHP
- Conditionally add associative element to array