Php implements the method of searching one-dimensional array elements and deleting the elements corresponding to the two-dimensional array.
This example describes how php can search for and delete elements in a one-dimensional array. Share it with you for your reference. The details are as follows:
Define a one-dimensional array. A two-dimensional array is as follows:
$ Fruit = array ('apple', 'Orange '); $ products = array ('name' => 'apple', 'price' => 23.4 ), array ('name' => 'Orange ', 'price' => 45.3), array ('name' => 'biscuit', 'number' => 5, 'price' => 34 ));
You need to find out from the $ products array whether the element has an intersection with the $ fruit element. If yes, keep it; otherwise, delete it.
Implementation Method:
Foreach ($ products as $ key => $ value) {if (! In_array ($ value ["name"], $ fruit) unset ($ products [$ key]);} array_values ($ products); // use unset () when destroying array elements, it is best to use array_values () to re-sort the array.
I hope this article will help you with php programming.