prueba de Diferencias Array Bidireccional - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.

Name: prueba de Diferencias Array Bidireccional fullscreencopydownloadembedprint


Your result can be seen below.

Result of php executing





Full code of prueba de Diferencias Array Bidireccional.php

  1. <?php
  2. $array1 = [
  3.     1=>'dato1',
  4.     2=>'dato2',
  5.     3=>'dato3',
  6.     4=>'dato4',
  7.     ];
  8.     
  9. $array2 = [
  10.     1=>'dato1',
  11.     2=>'dato2',
  12.     4=>'dato4',
  13.     6=>'dato6',
  14.     ];
  15.               
  16. $newArray1= array_diff($array1,$array2);
  17. $newArray2= array_diff($array2,$array1);
  18. $fullDiffArray= array_merge($newArray1,$newArray2);
  19.  
  20. echo '<pre>';
  21. echo var_dump($newArray1);
  22. echo var_dump($newArray2);
  23. echo var_dump($fullDiffArray);
  24. echo '</pre>';
File Description
  • prueba de Diferencias Array Bidireccional
  • PHP Code
  • 01 Jun-2021
  • 440 Bytes
You can Share it: