Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7838303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:03:52+00:00 2026-06-02T15:03:52+00:00

if i use the following code i got data in text file {title:sankas,description:sakars,code:sanrs} {title:test,description:test,code:test}

  • 0

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); 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T15:03:53+00:00Added an answer on June 2, 2026 at 3:03 pm

    use php’s file_put_content() more information here http://php.net/manual/en/function.file-put-contents.php

    Update :
    assuming that the data is correctly being passed. here is what you can do.

    $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";
    //using the FILE_APPEND flag to append the content.
    file_put_contents ($file, $json, FILE_APPEND);
    

    Update 2:

    if you want to access the value back from the text file. overlay.txt here is what you can do

    $content = file_get_contents($file);
    

    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.

    //this will convert the json data back to array
    $data = json_decode($json);
    

    and to access individual value you can do it like this if you have one row

    echo $data['title'];
    echo $data['code'];
    echo $data['description'];
    

    if you have multiple rows then you can use php foreach loop

    foreach($data as $key => $value)
    {
        $key contains the key for example code, title and description
        $value contains the value for the correspnding key
    }
    

    hope this helps you.

    Update 3:

    do it like this

    $jsonObjects = file_get_contents('./videos/overlay.txt');
    $jsonData = json_decode($jsonObjects);
    foreach ($jsonData as $key => $value) {
        echo $key . $value;
        //$key contains the key (code, title, descriotion) and $value contains its corresponding value
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got the following code that I am trying to use to access a
I use the following code for retrieve the data from my Sql DB.retrieve StudName
I use the following code for retrieve the data from mysql Student data Base.It
I've got the following code: http://jsfiddle.net/69MqZ/1/ As you can see grey text lines up
I've got a huge amount of data (stored in file, but it is irrelevant
I've got around 10 lines of data in a text file below containing the
I use the following code to retrieve the data from MySql database. GContnStr is
I use following code: Create a retry policy, when error, retry after 1 second,
I use VS2010, C# to develop Silverlight 4 app, I use following code in
I have an array of objects, and i use following code to get in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.