Support the ongoing development of Laravel.io →
posted 8 years ago
Input
Last updated 2 years ago.
0

you will need to read the file, json decode it to a php object set the required value, then write it again back json decoded.

File::put('path', json_encode($object));
Last updated 8 years ago.
0

You can also see this example: https://hdtuto.com/article/how-to-read-and-write-json-file-in-php-laravel

I hope it can help you

Last updated 6 years ago.
0

Use like ,

$data = json_decode($your_file_content,true),

then modify $data as normal php array, and before save use json_encode($data) and save data.

Last updated 6 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Jrecos jrecos Joined 12 Jun 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.