<?php
$day=array("Mon","Tue","Wed","Thu","Fri");
$subject=array();
   $result = mysqli_query($con,"SELECT * FROM timetable WHERE pmp='$usr'  " ); 
   $row = mysqli_fetch_array($result);
   $c = mysqli_num_rows($result);
   $id1=$row['id']+1;
   $result1 = mysqli_query($con,"SELECT * FROM timetable WHERE id='$id1'  " ); 
   $row1 = mysqli_fetch_array($result1);
   $i=0;
   $ind=1;
   while($i <= 4)
   {
	  $per=1;
	  while ($per <= $gym) 
	  {
		  $dayf=$day[$i].$per;
		  $lesson= $row["$dayf"];
		  if (!empty($lesson))
		  {
			$lesson=ltrim(rtrim($lesson));
			$subj=$row1["$dayf"];
			$mathima[$ind]=$lesson;
			$ar=explode('/',$subj);
			$subject[$ind]= $ar[1];
			$mathsubj[$ind]=ltrim($mathima[$ind])."/".ltrim($subject[$ind]);
			$ind++;
		  }
		  $per++;
      }
	  $i++;
   }
/*
   function filter($elmnt) {
    if ($elmnt != "null" && $elmnt != "" && $elmnt!='---' ) {
        return $elmnt;
    }
}

$sql = $dbcon->prepare("SELECT * FROM timetable where pmp=?");
$sql->execute([$usr]);
$row1=$sql->fetch(PDO::FETCH_ASSOC);
$idx=$row1['id']+1;
$sql = $dbcon->prepare("SELECT * FROM timetable where id=?");
$sql->execute([$idx]);
$row2=$sql->fetch(PDO::FETCH_ASSOC);

$x2=array_slice($row2, 3);
$x1=array_slice($row1, 3);
$subj=array_filter($x2,"filter");

$tmim=array_filter($x1,"filter");

	$i=1;
	foreach ($subj as $s)
	{
		$ar=explode('/',$s);
		$sbj[$i]=$ar[1];
		$i++;
	}
		$i=1;
		
	foreach ($tmim as $t)
	{
		$tm[$i]=$t."/".$sbj[$i];
		$i++;
	}
	*/
	//$sub=array_unique($sbj);
    //$mathsubj=array_unique($tm);   
$mathsubj=array_unique($mathsubj);
$ind=$ind-1;