remove-duplicate - 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.

<?php echo "
<html>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


Your result can be seen below.

Result of php executing





Full code of remove-duplicate.php

  1. <?php echo "
  2. <html>
  3.         <head>
  4.                 <style>
  5.                         table{
  6.                                 width:400px;
  7.                                 float:left;
  8.                         }
  9.                         table tr th{
  10.                                 background:red;
  11.                         }
  12.                         .bold{
  13.                                 font-weight:bold;
  14.                         }
  15.                 </style>
  16.         </head>
  17.         <body>
  18.                 <table>
  19.                         <tr>
  20.                                 <th>Fee</th>
  21.                                 <th>Amount</th>
  22.                         </tr>";
  23.                         $fee_cat = "";
  24.                        
  25.                         $cat = array('Annual Fee-Disability Scholarship','Annual Fee-First rank Scholarship','Monthly Fee-First rank Scholarship');
  26.                         $amount = array('1000-20','1000-10','560-5');
  27.                        
  28.                         foreach (array_combine($cat, $amount) as $cat => $amount){
  29.                                 $cat_ry = explode('-', $cat);
  30.                                 $amount_ry = explode('-', $amount);
  31.                                
  32.                                 $fee = $amount_ry[0];
  33.                                 $sch_cat = $cat_ry[1];
  34.                                 $sch = $amount_ry[1];
  35.                                 if($cat_ry[0] != $fee_cat){
  36.                                         $fee_cat = $cat_ry[0];
  37.                                         echo "
  38.                                         <tr>
  39.                                                 <td class='bold'>$fee_cat</td>
  40.                                                 <td>$fee</td>
  41.                                         </tr>
  42.                                         <tr>
  43.                                                 <td>$sch_cat</td>
  44.                                                 <td>$sch</td>
  45.                                         </tr>";
  46.                                 } 
  47.                         } echo "
  48.                         <tr>
  49.                 </table>
  50.         </body>
  51. </html>
  52. ";
  53.  
  54. ?>
File Description
  • remove-duplicate
  • PHP Code
  • 21 Oct-2018
  • 1011 Bytes
You can Share it: