@d_h_o_l

Как сделать переход строки при записи в json через php?

есть код записи в json файл
$file = file_get_contents('informationJson/usersStatistics.json');
        $taskList = json_decode($file,TRUE);
        $taskList[] = array('name'=>$user->data->username,
                            'follows'=>$user->data->counts->follows,
                            'followed_by'=>$user->data->counts->followed_by,
                            'media'=>$user->data->counts->media,
                            'images'=>$col_images,
                            'video'=>$col_video,
                            'likes'=>$col_likes,
                            'likes_images'=>$col_likes_images,
                            'likes_video'=>$col_likes_video,
                            'comments'=>$col_comments,
                            'comments_images'=>$col_comments_images,
                            'comments_video'=>$col_comments_video,
                            'likes'=>$col_likes,
                            );
        file_put_contents('informationJson/usersStatistics.json',json_encode($taskList));

вот результат записи
[{"name":"users181","follows":8,"followed_by":3,"media":5,"images":4,"video":1,"likes":8,"likes_images":7,"likes_video":1,"comments":1,"comments_images":1,"comments_video":0{"name":"users182","follows":8,"followed_by":3,"media":5,"images":4,"video":1,"likes":11,"likes_images":7,"likes_video":4,"comments":4,"comments_images":1,"comments_video":3}]

как сделать чтобы отображение в json файле было
[{
       "name":"users181",
       "follows":8,
       "followed_by":3,
       "media":5,
       "images":4,
       "video":1,
       "likes":8,
       "likes_images":7,
       "likes_video":1,
       "comments":1,
       "comments_images":1,
       "comments_video":0
}
{
       "name":"users182",
       "follows":5,
       "followed_by":3,
       "media":5,
       "images":4,
       "video":1,
       "likes":11,
       "likes_images":7,
       "likes_video":4,
       "comments":4,
       "comments_images":1,
       "comments_video":3
}]
  • Вопрос задан
  • 354 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы