this article describes the PHP to achieve one-dimensional array and two-dimensional array function. Share for you for reference, specifically as follows:

array repeats of the removal of

one dimensional array of repeated items:

use the array_unique function, the use of examples are as follows:

 <? PHP $aa=array ("1", "2", "3", "3", "2", ""); AA); print_r ($bb);? > 

results are as follows:

Array ([0] => 1 [1]); the repetition of the two-dimensional array: we discuss two cases of a two-dimensional array, one because of the value of a key name Can not repeat, delete duplicate items; another because the internal one-dimensional array can not be exactly the same, and delete duplicate items, the following example shows:

because the value of a key name can not be repeated, delete the repeat item

 < PHP function assoc_unique ($arr, $key) {$tmp_arr = array (); $v) {if (in_array ($v[$key], $tmp_arr)) / / search $v[$key] exists in the $tmp_arr array, if there is a return to true {unset ($arr[$k]);} else {$tmp_arr[] =}}; 1), array ('shopId'=> 1), array ('shopId' => 2), array ('shopId'=> 2); $key ='id'. 

PS: this station also has two simple and practical online text to repeat tools, recommended for everyone to use:

online removal of duplicate tools: 1.net/code/quchong

online text to duplicate tools:
http://tools.jb51.net/aideddesign/txt_quchong

more readers interested in PHP related content can view the site topic: ) operation techniques , PHP common traversal algorithm and Technique Summary ", "php string (string) Usage Summary " Rget= "_blank" >PHP basic grammar introductory tutorial , "php oriented object-oriented programming introductory tutorial " and "

, which you may be interested in:


This concludes the body part

This paper fixed link:http://www.script-home.com/php-to-achieve-one-dimensional-array-and-two-dimensional-array-to-re-function-examples.html | Script Home | +Copy Link

Article reprint please specify:PHP to achieve one-dimensional array and two-dimensional array to re function examples | Script Home

You may also be interested in these articles!