PHP implements the method of finding a specific value in a multidimensional array, multidimensional value
The example in this article describes how PHP implements finding a specific value in a multidimensional array. Share to everyone for your reference. Specific as follows:
Recently, you need to look up a multidimensional array to see if it contains a specific key and its corresponding value, and clear the data, such as:
$arr = Array (//For convenience of viewing, the array expression is not 0=>array (id =>1,name = "li") 1=>array (id =>2,name = "na") 2=>array ( ID =>3,name = "na")))
Want to achieve effect: Delete the record with ID 2:
Public Function Searcharray ($array, $key, $value) {foreach ($array as $KEYP + = $VALUEP) {if ($valuep [$key]== $value) { Unset ($array [$KEYP]);} return $array;}
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/1039183.html www.bkjia.com true http://www.bkjia.com/PHPjc/1039183.html techarticle PHP implements a method of finding a specific value in a multidimensional array, multidimensional value This article describes a method that PHP implements to find a specific value in a multidimensional array. Share to everyone for your reference. Specific ...