Difference between revisions of "Array unique recursive - PHP"

From List Wiki, organize pieces together
Jump to: navigation, search
(β†’β€ŽπŸ’‘ Solution)
Line 15: Line 15:
 
* [[file:listwiki-32.png]] List Wiki: [[{{TALKPAGENAME}}|Discussion forum for {{FULLPAGENAME}}]]
 
* [[file:listwiki-32.png]] List Wiki: [[{{TALKPAGENAME}}|Discussion forum for {{FULLPAGENAME}}]]
  
βˆ’
===πŸ“– Notes===
+
==πŸ“– Notes==
 
* You can help to provide additional answer to this question.
 
* You can help to provide additional answer to this question.
  
 
==🌎 Navigations==
 
==🌎 Navigations==
βˆ’
{{#categorytree:frequently asked questions - PHP|mode=pages|showcount=on}}
+
{{#categorytree:FAQ - PHP|mode=pages|showcount=on}}
 
==πŸ” More information==
 
==πŸ” More information==
 
* [[file:google-32.png|link=]] Google: [https://www.google.com/search?q={{urlencode:{{PAGENAME}}}} Search for {{PAGENAME}} on Google]
 
* [[file:google-32.png|link=]] Google: [https://www.google.com/search?q={{urlencode:{{PAGENAME}}}} Search for {{PAGENAME}} on Google]

Revision as of 01:10, 10 July 2019

❓ How to perform array_unique on a multidimensional array recursively?

πŸ’‘ Solution

function array_unique_recursive(&$arr){
	$arr = array_unique($arr, SORT_REGULAR);
	foreach ($arr as &$t){
		if (is_array($t)) $t = array_unique_recursive($t);
	}
	return $arr;
}
array_unique_recursive($yourArray);

πŸ’¬ Discussions

πŸ“– Notes

  • You can help to provide additional answer to this question.

🌎 Navigations

πŸ” More information

🐢 References