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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:07:26+00:00 2026-05-30T23:07:26+00:00

I am trying to handle a CSV file via php, and I have it

  • 0

I am trying to handle a CSV file via php, and I have it working. But there is this one array that I need to change based on a set of conditions.

$file_handle = fopen($path, "r");
while (!feof($file_handle) ) {
    $line_of_text = fgetcsv($file_handle, 100000);
    if($currency == "US"){
        $line_of_text[6] = str_replace ("if_you_find_this","change_to_this",$line_of_text[6]);
        $line_of_text[6] = str_replace ("if_you_find_this","change_to_this",$line_of_text[6]);
    } elseif($currency == "DE"){
        $line_of_text[6] = str_replace ("if_you_find_this","change_to_this",$line_of_text[6]);
        $line_of_text[6] = str_replace ("if_you_find_this","change_to_this",$line_of_text[6]);
}else {
        echo "Something with currency handling went wrong. Please contact support.";
}
    $data .=  $line_of_text[0] . "," . $line_of_text[1] . "," . $line_of_text[2] . "," . $line_of_text[4] . "," . $line_of_text[6] . "," .  $line_of_text[49] . "," .  $line_of_text[51] . "\n";

}
fclose($file_handle);

$new_file_handle = fopen($path, "w");
fwrite($new_file_handle, $data);

It’s not throwing any errors, but seems that the whole conditional block is being ignored. Help?

  • 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-30T23:07:27+00:00Added an answer on May 30, 2026 at 11:07 pm

    You’re not reading from $file_handle anywhere. feof($file_handle) will never be true. As posted, this code should loop forever.

    (BTW, using feof like this is generally not how you want to do it, for this reason among others. Better would be something like while (($line = however_you_read($file_handle)) !== FALSE).) Pretty much all the stream-reading functions return FALSE on any error, or on EOF.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple array that I am trying to handle. It consists of
I have a UIViewController subclass that I am trying to have handle the shake
I have a CSV file that contains over 80,000 rows and 100 columns. I'm
I am trying to make a website that reads from a csv file and
I have two .csv files containing correlation matrices exported from R. One file contains
I'm simply trying to handle an uploaded file and write it in a working
I'm trying to use IO::Handle to create a CSV file with Text::CSV . When
I'm trying to dynamically generate a csv file with some cells that will contain
I'm trying to handle Winsock_Connect event (Actually I need it in Excel macro) using
I'm trying to handle this possible exploit and wondering what is the best way

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.