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 6973687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:08:24+00:00 2026-05-27T17:08:24+00:00

I want to add a string (the value of a DOM element – $entry

  • 0

I want to add a string (the value of a DOM element – $entry = stripslashes($_GET["nameofmytextarea"]);) to the second line of myfile.csv (so as not to delete the header).

I don’t care about CSV stuff, everything is already formatted. Just treat it as a text string being added to a text file.

I don’t want anything complicated, just skip the first line and “append” above the second line: under the header but above all the other CSV lines.

How hard can that be?

  • 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-05-27T17:08:25+00:00Added an answer on May 27, 2026 at 5:08 pm
    $contents = explode("\n", file_get_contents('myfile.csv'), 2);
    file_put_contents('myfile.csv', $contents[0]."\n".$entry."\n".$contents[1]);
    

    This should work if the lines are separated by unix-lineendings.
    If the file first looks like this:

    header
    content
    content2
    

    and the code is run with $entry = 'test'; it will look like this afterwards:

    header
    test
    content
    content2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

can anybody help me ?? I want to add String value through coding in
I want to add JSON data with the following string value: json = d:\xyz\abc;
I have a list of string values that I want add to a hashtable
I want to add a string to a variable name that represents an integer.
If I have a string (010) and i want to add 1 to it
I have a string, and I want to add a number of spaces to
I used RollingFileAppender. And I want add a blank line to the log when
abstract class SettingSaver { public abstract void add(string Name, string Value); public abstract void
I'm building a simple filtering system, I simply want to add a string to
I want to add connection string to connect to mysql that are define 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.