fork download
  1. <?php
  2.  
  3. $lista1 = ["CURITIBA:SO","SP","BH","RS"];
  4. $lista2 = ["RJ","SC","AM","CURITIBA"];
  5.  
  6. function multiexplode($delimiters,$string) {
  7. $ready = str_replace($delimiters, $delimiters[0], $string);
  8. $launch = explode($delimiters[0], $ready);
  9. return $launch;
  10. }
  11.  
  12. foreach ($lista1 as $conteudo){
  13. $lista3 = multiexplode(array(":SB", ":SO"), $conteudo);
  14. }
  15.  
  16. $matches = array_intersect($lista3, $lista2);
  17.  
  18. for($i =0; $i <= 3; $i++){
  19.  
  20. if(array_key_exists($i, $matches)){
  21.  
  22. echo "O valor encontrado igual foi: $matches[$i]"."</br>";
  23.  
  24. }else{
  25.  
  26. echo "Não existe valor igual neste elemento da lista"."</br>";
  27. }
  28.  
  29. }
  30.  
  31. ?>
Success #stdin #stdout 0.01s 24580KB
stdin
Standard input is empty
stdout
Não existe valor igual neste elemento da lista</br>Não existe valor igual neste elemento da lista</br>Não existe valor igual neste elemento da lista</br>Não existe valor igual neste elemento da lista</br>