我想知道是否有人可以幫助我,我試圖找到一個腳本,將檢查我的整個數組,並刪除任何重複如果需要,然後吐出陣列在相同的格式。php刪除數組中的重複項
這裏是我的陣列的例子(你會看到有一些重複):
Array
(
[0] => Array
(
[0] => stdClass Object
(
[bid] => 34
[name] => Adrianos Pizza & Pasta
[imageurl] => sp_adrian.gif
[clickurl] => #
)
[1] => stdClass Object
(
[bid] => 42
[name] => Ray White Mordialloc
[imageurl] => sp_raywhite.gif
[clickurl] => http://www.raywhite.com/
)
[2] => stdClass Object
(
[bid] => 48
[name] => Beachside Osteo
[imageurl] => sp_beachside.gif
[clickurl] => http://www.beachsideosteo.com.au/
)
[3] => stdClass Object
(
[bid] => 57
[name] => Southern Suburbs Physiotherapy Centre
[imageurl] => sp_sspc.jpg
[clickurl] => http://www.sspc.com.au
)
[4] => stdClass Object
(
[bid] => 52
[name] => Mordialloc Travel and Cruise
[imageurl] => sp_morditravel.jpg
[clickurl] => http://www.yellowpages.com.au/vic/mordialloc/mordialloc-travel-cruise-13492525-listing.html
)
[5] => stdClass Object
(
[bid] => 37
[name] => Mordialloc Cellar Door
[imageurl] => sp_cellardoor.gif
[clickurl] =>
)
[6] => stdClass Object
(
[bid] => 53
[name] => Carmotive
[imageurl] => sp_carmotive.jpg
[clickurl] => http://www.carmotive.com.au/
)
)
[1] => Array
(
[0] => stdClass Object
(
[bid] => 55
[name] => 360South
[imageurl] => sp_360.jpg
[clickurl] =>
)
[1] => stdClass Object
(
[bid] => 40
[name] => Ripponlea Mitsubishi
[imageurl] => sp_mitsubishi.gif
[clickurl] =>
)
[2] => stdClass Object
(
[bid] => 57
[name] => Southern Suburbs Physiotherapy Centre
[imageurl] => sp_sspc.jpg
[clickurl] => http://www.sspc.com.au
)
[3] => stdClass Object
(
[bid] => 52
[name] => Mordialloc Travel and Cruise
[imageurl] => sp_morditravel.jpg
[clickurl] => http://www.yellowpages.com.au/vic/mordialloc/mordialloc-travel-cruise-13492525-listing.html
)
[4] => stdClass Object
(
[bid] => 37
[name] => Mordialloc Cellar Door
[imageurl] => sp_cellardoor.gif
[clickurl] =>
)
[5] => stdClass Object
(
[bid] => 53
[name] => Carmotive
[imageurl] => sp_carmotive.jpg
[clickurl] => http://www.carmotive.com.au/
)
)
[2] => Array
(
[0] => stdClass Object
(
[bid] => 44
[name] => Mordialloc Personal Trainers
[imageurl] => sp_mordipt.gif
[clickurl] => #
)
[1] => stdClass Object
(
[bid] => 36
[name] => Big River
[imageurl] => sp_bigriver.gif
[clickurl] =>
)
[2] => stdClass Object
(
[bid] => 52
[name] => Mordialloc Travel and Cruise
[imageurl] => sp_morditravel.jpg
[clickurl] => http://www.yellowpages.com.au/vic/mordialloc/mordialloc-travel-cruise-13492525-listing.html
)
[3] => stdClass Object
(
[bid] => 37
[name] => Mordialloc Cellar Door
[imageurl] => sp_cellardoor.gif
[clickurl] =>
)
[4] => stdClass Object
(
[bid] => 53
[name] => Carmotive
[imageurl] => sp_carmotive.jpg
[clickurl] => http://www.carmotive.com.au/
)
)
[3] => Array
(
[0] => stdClass Object
(
[bid] => 41
[name] => Print House Graphics
[imageurl] => sp_printhouse.gif
[clickurl] =>
)
[1] => stdClass Object
(
[bid] => 49
[name] => Kim Reed Conveyancing
[imageurl] => sp_kimreed.jpg
[clickurl] =>
)
[2] => stdClass Object
(
[bid] => 37
[name] => Mordialloc Cellar Door
[imageurl] => sp_cellardoor.gif
[clickurl] =>
)
[3] => stdClass Object
(
[bid] => 53
[name] => Carmotive
[imageurl] => sp_carmotive.jpg
[clickurl] => http://www.carmotive.com.au/
)
)
[4] => Array
(
[0] => stdClass Object
(
[bid] => 38
[name] => Lowe Financial Group
[imageurl] => sp_lowe.gif
[clickurl] => http://lowefinancial.com/
)
[1] => stdClass Object
(
[bid] => 58
[name] => Dicount Lollie Shop
[imageurl] => new dls logo.jpg
[clickurl] =>
)
[2] => stdClass Object
(
[bid] => 53
[name] => Carmotive
[imageurl] => sp_carmotive.jpg
[clickurl] => http://www.carmotive.com.au/
)
)
[5] => Array
(
[0] => stdClass Object
(
[bid] => 45
[name] => Mordialloc Sporting Club
[imageurl] => msc logo.jpg
[clickurl] =>
)
[1] => stdClass Object
(
[bid] => 33
[name] => Two Brothers
[imageurl] => sp_2brothers.gif
[clickurl] => http://www.2brothers.com.au/
)
)
[6] => Array
(
[0] => stdClass Object
(
[bid] => 46
[name] => Patterson Securities
[imageurl] => cmyk patersons_withtag.jpg
[clickurl] =>
)
[1] => stdClass Object
(
[bid] => 56
[name] => Logical Services
[imageurl] => sp_logical.jpg
[clickurl] =>
)
)
[7] => Array
(
[0] => stdClass Object
(
[bid] => 59
[name] => Pure Sport
[imageurl] => sp_psport.jpg
[clickurl] => http://www.puresport.com.au/
)
[1] => stdClass Object
(
[bid] => 51
[name] => Richmond and Bennison
[imageurl] => sp_richmond.jpg
[clickurl] => http://www.richbenn.com.au/
)
)
[8] => Array
(
[0] => stdClass Object
(
[bid] => 39
[name] => Main Street Mordialloc
[imageurl] => main street cafe.jpg
[clickurl] =>
)
[1] => stdClass Object
(
[bid] => 50
[name] => Letec
[imageurl] => sp_letec.jpg
[clickurl] => www.letec.biz
)
)
[9] => Array
(
[0] => stdClass Object
(
[bid] => 54
[name] => PPM Builders
[imageurl] => sp_ppm.jpg
[clickurl] => http://www.hotfrog.com.au/Companies/P-P-M-Builders
)
[1] => stdClass Object
(
[bid] => 43
[name] => Systema
[imageurl] => sp_systema.gif
[clickurl] =>
)
)
)
你有很多嵌套數組。你的意思是重複的?例如。第一個子數組包含一個ID爲「57」的對象。這是否意味着,這個對象應該在第二個(和所有進一步的)子陣列中被刪除? – 2010-05-18 21:35:17
*可能重複*:http://stackoverflow.com/questions/307674/how-to-remove-duplicate-values-from-a-multi-dimensional-array-in-php – 2010-05-18 21:38:07
是的,這就是我之後..我知道它是多維的,但是如果有任何來自任何子陣列的任何東西的重複,它應該被刪除:) – SoulieBaby 2010-05-18 21:38:10