This article introduces how to delete element values from the php array header. For more information, see. This section describes how to delete a value from the php array header, You can use the php array function array_shift () to delete the function and return the elements found in the array. The result is that if a numeric value is used, all corresponding values are moved down, and the array using the correlated key is not affected. The format is mixed array_shift (array) Example: delete the first element in the $ fruits array, apple:
This article introduces how to delete values from the array header. here we will add a method to delete elements from the array for your reference. Delete elements from the php array If you want to delete an element from an array, you can use the unset directly. For example:
But something strange happened. after print_r ($ arr), the result is not that, the final result is Array ([0] => a [2] => c [3] => d) How can we fill in the missing elements and re-index the array? In this case, the array_splice () function is required:
In this way, after print_r ($ arr), the result is Array ([0] => a [1] => c [2] => d ). Let's take a look at this and hope to help you understand how to delete the specified element value in the php array. |