<?php 
if(file_exists('../../../'.$_REQUEST['tenant'].'/config.php')){require_once('../../../'.$_REQUEST['tenant'].'/config.php');}
if(file_exists('/config.php')){require_once('/config.php');}
$master=[];
foreach(range(1,500) as $l){
${"array_$l"}=[];

}

foreach(range(1,500) as $l){
foreach ($_REQUEST['data']as $key => $val) {
$d=explode("-",$val);

if ($d[3] == $l) {

${"array_$d[3]"}[]=$val;

}else{}
}
}


foreach(range(1,500) as $l){
if(!empty(${"array_$l"})) {$master[]=${"array_$l"};}
}

$ret=json_encode($master);echo $ret;