Disclaimer: I am very unfamiliar with PHP. The answers I have seen floating around Stack don't seem applicable to my situation. This could be due to my unfamiliarity.
I need to write to an existing array in a JSON file:
[
[
// data should be written to this array
],
[]
]
My PHP looks like so:
<?php
$ip = $_POST["ip"];
$likes = "../data/likes.json";
$fp = fopen($likes, "a");
fwrite($fp, json_encode($ip) . ", ");
fclose($fp);
?>
When the PHP runs it writes to the end of the file like so (as you'd expect):
[
[
],
[]
]"data",
How do I resolve my PHP to do so?