+ 1

Help me arrive at the output of this code guys. Am really lost. The output is 5,4

snippet? $x = array("aaa", " "; "ccc", "ddd", " "); $y = array_unique($x); echo count ($x). ",".count($y);

10th May 2019, 9:27 AM
Samuel Kinuthia
Samuel Kinuthia - avatar
3 Réponses
0
$y => counts the unique elements of the array (there are two elements => " ", so unique are 4 elements). count ($x) => return the number of all elements in the array => there are 5 elements. Hope it helps you.
10th May 2019, 9:34 AM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
0
Thanks for that. I never really got to understand the array_unique function until now. Problem solved.
10th May 2019, 9:39 AM
Samuel Kinuthia
Samuel Kinuthia - avatar
0
Samuel Kinuthia , I'm glad to help 😉
10th May 2019, 2:44 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar