<?php
$arr = array(0 => array("id"=>1,"name"=>"cat 1"),
1 => array("id"=>2,"name"=>"cat 2"),
2 => array("id"=>3,"name"=>"cat 1")
);
$arr = array_filter($arr, function($ar) {
return ($ar['name'] == 'cat 1');
//return ($ar['name'] == 'cat 1' AND $ar['id'] == '3');// you can add multiple conditions
});
echo "<pre>";
print_r($arr);
?>
Ref: http://php.net/manual/en/function.array-filter.php
Related Contents:
- Search for a key in an array, recursively
- Recursive function to generate multidimensional array from database result
- Find a matching or closest value in an array
- create array tree from array list [duplicate]
- Cartesian Product of N arrays
- PHP hierarchical array – Parents and childs
- Check if a specific value exists at a specific key in any subarray of a multidimensional array
- Check if specific array key exists in multidimensional array – PHP
- How to check if a specific value exists at a specific key in any subarray of a multidimensional array?
- Recursively sort keys of a multidimensional array
- Converting an array from one to multi-dimensional based on parent ID values
- How can I use in_array if the needle is an array?
- How to Flatten a Multidimensional Array?
- Remove empty array elements
- PHP – Check if two arrays are equal
- Access array returned by a function in php
- Are arrays in PHP copied as value or as reference to new variables, and when passed to functions?
- PHP Constants Containing Arrays?
- I have an array of integers, how do I use each one in a mysql query (in php)? [duplicate]
- php multi-dimensional array remove duplicate [duplicate]
- Convert stdClass object to array in PHP
- Difference in accessing arrays in PHP 5.3 and 5.4 or some configuration mismatch?
- Get difference between associative rows of two 2-dimensional arrays
- php group by SUM using multi dimensional array
- php – How do I fix this illegal offset type error
- php array behaving strangely with key value 07 & 08
- PHP – Convert multidimensional array to 2D array with dot notation keys
- Search for PHP array element containing string [duplicate]
- Sort array of objects by one property
- How to get the last element of an array without deleting it?
- PHP array_filter with arguments
- Is it necessary to declare PHP array before adding values with []?
- Merge two indexed arrays of indexed arrays based on first column value
- PHP compare array
- Is there a way to loop through a multidimensional array without knowing it’s depth?
- php getting unique values of a multidimensional array [duplicate]
- Group rows in an associative array of associative arrays by column value and preserve the original first level keys
- PHP combine two associative arrays into one array
- Merge two 2d arrays by shared column value
- Count “truthy” values in a 2d array
- Print $_POST variable name along with value
- mysql select query within a serialized array
- why is $_REQUEST empty
- How to create an empty array in PHP with predefined size?
- PHP object like array
- $_POST max array size
- What is the difference between array_udiff_assoc() and array_diff_uassoc()?
- Concatenate values of n arrays in php
- Sort multidimensional array by date column, then use other column values if dates are the same
- laravel collection to array