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

  1. <?
  2.     $userToDisplay = readline('Enter Name:');
  3.     
  4.         $results = array(
  5.     array('year' => '2021', 'name'=>'peter', 'course'=>'coursename one', 'grade'=>'A'),
  6.     array('year' => '2021', 'name'=>'td', 'course'=>'coursename six', 'grade'=>'B'),
  7.     array('year' => '2021', 'name'=>'doe', 'course'=>'coursename five', 'grade'=>'D'),
  8.     array('year' => '2021', 'name'=>'john', 'course'=>'coursename four', 'grade'=>'C'),
  9.     array('year' => '2021', 'name'=>'peter', 'course'=>'coursename THREE', 'grade'=>'D*'),
  10.     array('year' => '2021', 'name'=>'doe', 'course'=>'coursename TWO', 'grade'=>'A*')
  11. );
  12. $first = $results[0]['name'];
  13. //echo $first;
  14.     foreach($results as $result){
  15.         $user = $result['name'];
  16.         $year = $result['year'];
  17.         $course = $result['course'];
  18.         $grade = $result['grade'];
  19.     }
  20.     
  21.     print_r($user);
  22.     print_r($year);
  23.     print_r($course);
  24.     print_r($grade);
  25.  
  26.     ?>
  27.     
  28.     
  29.     
  30. <div class=''> <!--container-->
  31.   <div class='heading'>
  32.     <h1>Exam Results for <? echo $user?></h1>
  33.   </div>
  34.   <br>
  35.   <div class='content-center'>
  36.     <table class='table-auto mx-auto'>
  37.     <?
  38.         $results = array(
  39.     array('year' => '2021', 'name'=>'peter', 'course'=>'coursename one', 'grade'=>'A'),
  40.     array('year' => '2021', 'name'=>'td', 'course'=>'coursename six', 'grade'=>'B'),
  41.     array('year' => '2021', 'name'=>'doe', 'course'=>'coursename five', 'grade'=>'D'),
  42.     array('year' => '2021', 'name'=>'john', 'course'=>'coursename four', 'grade'=>'C'),
  43.     array('year' => '2021', 'name'=>'peter', 'course'=>'coursename THREE', 'grade'=>'D*'),
  44.     array('year' => '2021', 'name'=>'doe', 'course'=>'coursename TWO', 'grade'=>'A*')
  45.     );
  46. $first = $results[0]['name'];
  47. //echo $first;
  48.     foreach($results as $result){
  49.         echo $result['year'];
  50.     }
  51.  
  52.     ?>
  53.       <thead>
  54.         <tr>
  55.            <td>
  56.             Academic Year
  57.           </td>
  58.           <td>
  59.             COURSE NAME
  60.           </td>
  61.           <td>
  62.             GRADE
  63.           </td>
  64.         </tr>
  65.       </thead>
  66.  
  67.       <tbody>
  68.         <tr>
  69.           <td>
  70.             <? echo $year?>
  71.           </td>
  72.           <td>
  73.            <? echo $course ?>
  74.           </td>
  75.           <td>
  76.             <?echo $grade?>
  77.           </td>
  78.         </tr>
  79.  
  80.         <tr>
  81.           <td>
  82.             2022
  83.           </td>
  84.           <td>
  85.            second name of course goes here
  86.           </td>
  87.           <td >
  88.             A
  89.           </td>
  90.         </tr>
  91.         <tr>
  92.           <td>
  93.             2022
  94.           </td>
  95.           <td>
  96.            second name of course goes here
  97.           </td>
  98.           <td >
  99.             A
  100.           </td>
  101.         </tr>
  102.  
  103.         <tr>
  104.           <td>
  105.             2022
  106.           </td>
  107.           <td>
  108.            second name of course goes here
  109.           </td>
  110.           <td >
  111.             A
  112.           </td>
  113.         </tr>
  114.       </tbody>
  115.     </table>
  116.   </div><!--content-centre-->
  117.   <br>
  118.  
  119.   <div class='band'>
  120.     <a class='hover:text-red-500 text-blue-600 visited:text-purple-600' href=''>Download Results Statement</a>
  121.   </div>
  122.   <br>
  123.   <div class='band'>
  124.     <a class='hover:text-red-500 text-blue-600 visited:text-purple-600' href=''>Barton Peveril Candidate Handbook</a>
  125.   </div>
  126.  
  127. </div><!--closing container-->
  128.  
  129.  
  130. <?php
  131. $results = array(
  132.     array('year' => '2021', 'name'=>'peter', 'course'=>'coursename one', 'grade'=>'A'),
  133.     array('year' => '2021', 'name'=>'td', 'course'=>'coursename six', 'grade'=>'B'),
  134.     array('year' => '2021', 'name'=>'doe', 'course'=>'coursename five', 'grade'=>'D'),
  135.     array('year' => '2021', 'name'=>'john', 'course'=>'coursename four', 'grade'=>'C'),
  136.     array('year' => '2021', 'name'=>'peter', 'course'=>'coursename THREE', 'grade'=>'D*'),
  137.     array('year' => '2021', 'name'=>'doe', 'course'=>'coursename TWO', 'grade'=>'A*')
  138. );
  139. $first = $results[0]['name'];
  140. //echo $first;
  141.  
  142.  
  143. ?>
  144.  
File Description
  • phpPlay
  • PHP Code
  • 21 Jul-2021
  • 3.75 Kb
You can Share it: