I am trying to call array_push to add data sent via a GET request to my json array that holds registration ids for my GCM Clients
<?php
//read current regids
$myfile = fopen("regids.json", "r") or die("Unable to open file!");
$current_regids = fread($myfile,filesize("regids.json"));
// decode json
$decoded_json= json_decode($current_regids);
//save to php format array
$array = array($decoded_json);
//close file
fclose($myfile);
//get registration id
$regid = $_GET["regid"];
//push new reg id into array
array_push($array,$regid);
echo json_encode($array);
?>
The JSON should be as follows
["regid1","regid2", "regid3","regid4"]
However when I run the code it inorder to array_push "regid5" it gives me this
[["regid1","regid2","regid3","regid4"],"regid5"]
Its a major headache