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

  1. <?php
  2. function digitValue($str){
  3.         $n = filter_var($str, FILTER_SANITIZE_NUMBER_INT);
  4.         $length = strlen($n);
  5.         for ($i = 0; $i < $length; $i++){
  6.                 if (is_numeric($n[$i]))
  7.                 $zero = $length - $i -1;
  8.                 echo $n[$i] . str_repeat(0,$zero) ."\n";
  9.        
  10.         }
  11. }
  12.  
  13. digitValue('9,327,421');
  14.  
  15. function triangle(){
  16.     $str = range(1,9);
  17.         $length = count($str);
  18.         for ($i = 0; $i < $length; $i++){
  19.         $x = array_slice($str,$i);
  20.         echo implode(' ', $x) . "\n";
  21.         }
  22. }
  23.  
  24. triangle();
  25.  
  26. function odde($n){
  27.     echo '[';
  28.     for ($i = 1; $i < $n; $i++) {
  29.         if (($i % 2) != 0) {
  30.             echo $i . ' ';
  31.         }
  32.     }
  33.     echo ']';
  34. }    
  35.  
  36. odde(15);
File Description
  • 112
  • PHP Code
  • 22 Mar-2023
  • 637 Bytes
You can Share it: