PHP array deduplicate data example_PHP tutorial

WBOY
Release: 2016-07-13 10:36:51
Original
942 people have browsed it

Repeating data starting with a number such as:

Copy code The code is as follows:

Array (
[0 ] => 100
[k1] => 100
[1] => 2123
[k2] => 2123 )

This method can be used as To remove the values ​​whose numbers are keys, first sort the array in reverse order by key, and then use the array_unique method to remove duplicate values.
It cannot be applied to the following situations: different key values ​​have the same value

Copy code The code is as follows:

function array_unique_value($arr = array()){
array_multisort($arr , SORT_DESC, array_keys($arr));
print_r(array_unique($arr));
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/736858.htmlTechArticleRepeating data starting with a number such as: Copy code The code is as follows: Array ( [0] = 100 [k1] = 100 [1] = 2123 [k2] = 2123 ) This method can remove the value with a number as the key. First, convert the array according to...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!