bayağı bir karştırmışsınız
şu yaptğım örneği çalıştırıp inceleyin
<?php
$_temp = array();
$user_id = 923;
$_temp[] = array(
'sures' => 25,
'vidid' => 8888888888,
'type' => 'match',
'tips' => 'kesirler',
'total' => 25
);
$json_file = dirname(__FILE__).'/new/'.$user_id.'-'.$vidid.'.json';
if(file_exists($json_file)){
$json = json_decode(file_get_contents($json_file),true);
$json = array_merge($json,$_temp);
}
file_put_contents($json_file,json_encode($json));
////
$_temp2 = array();
$_temp2[] = array(
'sures' => 225,
'vidid' => 28888888888,
'type' => '2match',
'tips' => '2kesirler',
'total' => 225
);
//hepsinin basina 2 ekleidm
if(file_exists($json_file)){
$json = json_decode(file_get_contents($json_file),true);
//dosyadaki json string verilerini alip array a donsturduk
$json = array_merge($json,$_temp2);
//olusturdugumuz _temp2 arrayi ile dosyadaki kayitli arrayimizi birlestirdik
}
file_put_contents($json_file,json_encode($json));
print_r(json_decode(file_get_contents($json_file),true));