I have a JSON file named 'jason_file.json' that is look like:
[
{"name":"name1", "city":"city1", "country":"country1"},
{"name":"name2", "city":"city2", "country":"country2"},
{"name":"name3", "city":"city3", "country":"country3"},
{"name":"name4", "city":"city4", "country":"country4"},
{"name":"name5", "city":"city5", "country":"country5"}
]
Using for loop, I want to remove first two objects from file and save remaining objects in the same order in the 'jason_file.json'. Required result should be:
[
{"name":"name3", "city":"city3", "country":"country3"},
{"name":"name4", "city":"city4", "country":"country4"},
{"name":"name5", "city":"city5", "country":"country5"}
]
How can I do it?
file_get_contents,file_put_contents,json_decode,json_encodeand someunset. Could you give it a go yourself? It is excellent practice.