File "envoi_json.php"
Full Path: /home/analogde/www/Design/fileman/Fusion/Table/Debug/envoi_json.php
File size: 1.26 KB
MIME-type: text/x-php
Charset: utf-8
<?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("aaadata.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 "<br>";
echo "PHP recoit un objet de type " .gettype($response), "</br>";
echo "Nombre de colonne " .count($response), "</br>";
echo "<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>";
}*/
echo $response[$i];
echo "<br>";
}
// https://www.w3docs.com/snippets/php/save-php-array-to-mysql.html
// serialize
?>