Problem with json output data shows Invalid
Here is what i want to do, Get api response from other server in json format, decode to array and extract the required data and save the extracted data to newArray and then encode the newArray back to json and print to screen But the problem i face is the printed json shows invalid json format When i look at the rawdata i notice there is no [ at the begin and no ] at the end Also there is no , coma for next data block.
Here is my code
$array = json_decode($eng_sub, 1 );
for ($i = 0; $i < count($array); $i++ ){
$resp_array['Movie Name'] = $array[$i]['MovieName'];
$resp_array['Movie Year'] = $array[$i]['MovieYear'];
$resp_array['Language'] = $array[$i]['LanguageName'];
$resp_array['Link'] = $array[$i]['ZipDownloadLink'];
$json = json_encode($resp_array);
print_r ($json);
}
And here is the response from my code after re-encoded to json
{"Movie Name":"Avatar","Movie Year":"2009","Language":"Urdu","Link":"https:\/\/dl.opensubtitles.org\/en\/download\/src-api\/vrf-f52f0bb6\/subad\/7006619"}{"Movie Name":"TEKNO3D.com Avatar 2009 4K VISIONPLUSHDR-1000 4:2:0 Edition S01","Movie Year":"2009","Language":"Urdu","Link":"https:\/\/dl.opensubtitles.org\/en\/download\/src-api\/vrf-f5410bb6\/subad\/7600673"}
Im doing this in XAMPP PHP 7