我在PHP中有一个看起来像这样的数组:
I have an array in PHP that looks like this:
[0]=> array(2) { ["name"]=> string(9) "My_item" ["url"]=> string(24) "www.my-url/" } [1]=> array(2) { ["name"]=> string(9) "My_item" ["url"]=> string(24) "www.my-url2/" }这两个项目中名称"中的两个值相同.我想整理出这样的重复项.
The two values in "name" are the same in this two items. I want to sort out duplicates like this.
如何通过检查名称"值来创建唯一数组?
How do I create an unique array by checking the "name" value?
推荐答案基本上
foreach($your_array as $element) { $hash = $element[field-that-should-be-unique]; $unique_array[$hash] = $element; }