test2 - 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 test2.php

  1. <?php 
  2. class Pizdec {
  3.     private $input;
  4.     
  5.     function __construct($input) {
  6.         $this->input_arr = $input; 
  7.     }
  8.     
  9.     function arr_sort() {
  10.         $arr = $this->input_arr;
  11.         
  12.         // var1: use pre-defined method;
  13.         // sort($arr);
  14.         // var2: use bulb sorting
  15.         for($i = 0; $i < count($arr); $i++) {
  16.             for($j = 0; $j < count($arr); $j++) {
  17.                 if($arr[$i] < $arr[$j]) {
  18.                     $temp = $arr[$j];
  19.                     $arr[$j] = $arr[$i];
  20.                     $arr[$i] = $temp;
  21.                 }
  22.             }
  23.         }
  24.         
  25.         return $arr;
  26.     }
  27. }
  28.  
  29. $array = array(12,4,60, 0);
  30. $pizdec = new Pizdec($array);
  31. $results = $pizdec->arr_sort();
  32. var_dump($results);
  33.  
File Description
  • test2
  • PHP Code
  • 16 Jan-2022
  • 741 Bytes
You can Share it: