<?php

$csv = fopen('session.csv', 'r');

$aCsv = [];
while ($f = fgetcsv($csv, null, ';')) {
    $aCsv[] = $f;
}
fclose($csv);

//$_POST['description'] = str_replace( PHP_EOL, '<br />', $_POST['description'] );
              $term = $_GET['term'];

$aJson = [];
$bFound = false;
foreach ($aCsv as & $row) {
    if ( strpos($row[1], $term ) !== false )  {
		  //echo ($_GET['name']);
		//$_GET['name'] = $row[0] ;
		//$_GET['floor']= $row[2] ;
       // $row[3] = ($_POST['description']);
        //$bFound = true;
		//console.log("nasiel")
    
            $aJson[] = ['id' => $row[0], 'value' => $row[1], 'floor' => $row[2]];
    
       // break;
    }
}

echo json_encode($aJson);

exit();