$name, "post" => $post); //open the file $myfile = file_get_contents($filename); //decode file to php data and store in array temp $temp = json_decode($myfile); //add the array newpost to the temp array_push($temp, $newpost); //enocde php data back to json $json = json_encode($temp); //save json to file name file_put_contents($filename, $json); ?>