php tutorial delete array elements and delete duplicate array function This article is mainly about the deletion of the php array value Oh, tell you how to delete an array of elements at the specified location, the two tell you to use the array_keys function to delete the array of duplicate elements. * /
$ a = array ("red", "green", "blue", "yellow"); count ($ a); // get 4 unset ($ a [1]); // Delete the second element count ($ a); // get 3 Echo $ a [2]; // array only three elements, wanted to get the last element, but got blue, Echo $ a [1]; / / No value
// array array_splice (array input, int offset [, int length [, array replacement]]) // array_splice () is actually a function that replaces an array element, but simply deletes the element without substitution. Here's how to use array_splice (): $ b = array ("red", "green", "blue", "yellow"); array_splice ($ a, 1,1);
// See below a more comprehensive delete duplicate values and delete the specified array element
// delete the function of repeating elements in the array function delmember (& $ array, $ id) { $ size = count ($ array); for ($ i = 0; $ i <$ size - $ id - 1; $ i ++) { $ array [$ id + $ i] = $ array [$ id + $ i + 1]; } unset ($ array [$ size - 1]); } ?>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.