<?php $string = "car apple computer car"; $string2 = "car apple computer"; function hasSameWords($string) { $array = explode(' ', $string); $count = count($array); $unique = array_unique($array); $uniqueCount = count($unique); return $uniqueCount < $count; } echo hasSameWords($string) ? 'true' : 'false'; echo hasSameWords($string2) ? 'true' : 'false';
You have javascript disabled. You will not be able to edit any code.