Support the ongoing development of Laravel.io →
posted 7 years ago
Input
Last updated 1 year 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 7 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 5 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 5 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.