I have a .txt file where I have list of Windows 8 apps, written in JSON, that is being used in an Windows 8 app. I want to be able to have an online form, where I can input a ne
Don't use FILE_APPEND
. You're already appending the new entry to $content
, so you need to rewrite the file completely, not add the new array after the old one.
$content = json_decode( file_get_contents( $savePath ) , true );
//add the new data
$content[] = array(
'backgroundImage' => $bi ,
'description' => $ad,
'extraImages' => $ei,
'group' => array('backgroundImage' => $gbi, 'description' => $gd, 'groupImage' => $gi, 'key' => $gk, 'shortTitle' => $gst, 'title' => $gt,),
'teacherReview' => $tr,
'rating' => $rating,
'shortTitle' => $st,
'tileImage' => $ti,
'title' => $title
);
//encode the new data
$content_json = json_encode($content);
file_put_contents( $savePath , $content_json );