<?php

	$str_json = file_get_contents('php://input'); //($_POST doesn't work here)
	$response = json_decode($str_json, true); // decoding received JSON to array

	// json file name 
	//$filename = "transfert.json"; ???
	
	// Read the JSON file in PHP 
	//$data = file_get_contents($filename);  ???
	
	
	//$json = json_encode(array('data' => $array));

//write json to file
	if (file_put_contents("data.json", $str_json))
		echo "JSON file created successfully...";
	else 
		echo "Oops! Error creating json file...";
	
	//echo "----> " .count($response);

	// OK  ABC
	//echo " ----->>> "	.$response[0][0];
	
	// nombre de colonne dans $response[0]
	//echo " ----->>> "	.count($response[0]);
	
	// lecture 
	
	echo "PHP recoit un objet de type " .gettype($response), "</br>";
	
	echo "Nombre de colonne " .count($response), "</br>";
	
	for ($i = 0; $i < count($response); $i++) 
	{
		
	
		/*for ($j = 0; $j < count($response[$i]); $j++) 
		{
			//echo "Nombre de ligne par colonne " .count($response[$j]), "</br>";
		
			echo $response[$i][$j];
			echo "<br>";
		}*/
		
		/*if(empty($response[$i]))
		{ 
			echo "Empty string " .$response[$i]; 
		} 
		else 
		{ 
			echo "Not empty " .$response[$i]; 
		} */
		
		
		
		
		echo $response[$i][0] ." ****** " .$response[$i][1] ;
		echo "<br>";

	}

		//var_dump($response);
	
	// https://www.w3docs.com/snippets/php/save-php-array-to-mysql.html
	
	// serialize
	

?>