Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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";
- }
- $json = file_get_contents('http://localhost/01/20-01-2018.json');
- $data = json_decode($json);
Add Comment
Please, Sign In to add comment