fork(2) download
  1. <?php
  2.  
  3. function findCoincidences($textOfArray) {
  4. $output = "";
  5.  
  6. // Locate all the duplicated Strings (keys and values)
  7. preg_match_all('/".*?"/', $textOfArray, $matches);
  8.  
  9. // Make array where key = string, and value = repetitions
  10. $arrayCoinc = array_count_values($matches[0]);
  11.  
  12. $output = "==== COINCIDENCES ====<br>";
  13. foreach ($arrayCoinc as $k => $v){
  14. if ($v > 1){
  15. $output .= "<b>".$k."</b> Found:".$v."<br>";
  16. }
  17. }
  18. return $output;
  19. }
  20.  
  21. $array1 = '$array = ["hello"=>1, "hello"=>2,];';
  22.  
  23. echo findCoincidences($array1);
  24.  
  25. // your code goes here
Success #stdin #stdout 0.02s 24412KB
stdin
Standard input is empty
stdout
==== COINCIDENCES  ====<br><b>"hello"</b> Found:2<br>