doppioni - 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.



Your result can be seen below.

Result of php executing





Full code of doppioni.php

  1. <?php
  2. $a=array(-1,1,2,2,3,4,5,5);
  3. $p=0;
  4.  
  5.   for($k=0; $k<count($a)-1;$k++)
  6.      if($a[$k]==$a[$k+1]){
  7.        $p++;
  8.        $a[$k]="*";
  9. }
  10. var_dump($a);
  11. print"\n";
  12. print $p;
  13. $b=array();
  14.  
  15.  for($k=0; $k<count($a); $k++)
  16.     $b[count($b)]=$a[$k];
  17.       if($a[$k]!="*"){
  18.         $b[count($b)]=$a[$k];
  19.         
  20.       }
  21. var_dump($b);
  22. ?>
  23.  
File Description
  • doppioni
  • PHP Code
  • 22 Jan-2022
  • 327 Bytes
You can Share it: