I created an .json file using the following code:
<?php
function get_data(){
$connect = mysqli_connect("localhost", "root", "", "videos");
$query = "SELECT * FROM 'tb_indice'";
$result = mysqli_query($connect, $query);
$data = array();
while($row = mysqli_fetch_array($result)){
$data[] = array(
'id' => $row["id"],
'titulo' => $row["titulo"],
'video' => $row["video"],
);
}
return json_encode($data);
}
$file_name = date('d-m-Y') . '.json';
if(file_put_contents($file_name, get_data())){
echo $file_name . 'Arquivo criado';
} else {
echo "Ocorreu algum erro na criação do arquivo .json";
}
And I'm using:
$json = file_get_contents('http://localhost/01/20-01-2018.json');
$data = json_decode($json);
to return.
However I would like to search in the file (20-01-2018.json) parameters, example: link {title will be searched here)