if i use the following code i got data in text file
{"title":"sankas","description":"sakars","code":"sanrs"}
{"title":"test","description":"test","code":"test"}
but my code is working on
{"title":"sankas","description":"sakars","code":"sanrs"}
so i could not add more rows.where i want to change to get correct results.
$info = array();
$folder_name = $this->input->post('folder_name');
$info['title'] = $this->input->post('title');
$info['description'] = $this->input->post('description');
$info['code'] = $this->input->post('code');
$json = json_encode($info);
$file = "./videos/overlay.txt";
$fd = fopen($file, "a"); // a for append, append text to file
fwrite($fd, $json);
fclose($fd);
use php’s
file_put_content()more information here http://php.net/manual/en/function.file-put-contents.phpUpdate :
assuming that the data is correctly being passed. here is what you can do.
Update 2:
if you want to access the value back from the text file. overlay.txt here is what you can do
if you want to fetch title, code, and description separately. and if the string is in json then you need to convert it into array first by using.
and to access individual value you can do it like this if you have one row
if you have multiple rows then you can use php foreach loop
hope this helps you.
Update 3:
do it like this