To remove elements from a multidimensional array based on a specific value, you can utilize the following method:
function removeElementWithValue($array, $key, $value) { foreach ($array as $subKey => $subArray) { if ($subArray[$key] == $value) { unset($array[$subKey]); } } return $array; }
To utilize this function, pass in the multidimensional array, the key you're matching against, and the value you want to remove. For instance, to remove all sub-arrays where the "year" key has a value of 2011, call the function as follows:
$array = removeElementWithValue($array, "year", 2011);
This will modify the original $array by eliminating any sub-arrays meeting the specified criteria.
Atas ialah kandungan terperinci Bagaimana untuk mengalih keluar Elemen daripada Tatasusunan Berbilang Dimensi Berdasarkan Nilai?. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!