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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:08:15+00:00 2026-06-02T09:08:15+00:00

I have a csv file which I need to remove parts from, and it’s

  • 0

I have a csv file which I need to remove parts from, and it’s 7017 lines long, so I’m using php to remove certain parts and put it back together, the relevant code for it is below.

$rows;
$count = 0;
while (($row = fgetcsv($files, 56000)) !== false) {
  $rows[$count] = $row;
  if (stristr($rows[$count][8], "Features:")) {
    $rows[$count][8] = str_replace("Features:", "features", $rows[$count][8]);
    $rows[$count][8] = str_replace(":", "", $rows[$count][8]);
    $rows[$count][8] = explode("features", $rows[$count][8]);
    if (isset($rows[$count][8][1])) {
      $rows[$count][8][1] = str_replace("Compatible", "compatible", $rows[$count][8][1]);
      $rows[$count][8][1] = explode("compatible", $rows[$count][8][1]);
      //$rows[$count][8][1] = explode("Compatible", $rows[$count][8][1]); produces error if  used
      $rows[$count][8][1] = explode("-", $rows[$count][8][1][0]);
    } else if (isset($rows[$count][8][0])) {
      $rows[$count][8][0] = str_replace("Compatible", "compatible", $rows[$count][8][0]);
      $rows[$count][8][0] = explode("compatible", $rows[$count][8][0]);
      //$rows[$count][8][0] = explode("Compatible", $rows[$count][8][0]); produces error if  used
      $rows[$count][8][0] = explode("-", $rows[$count][8][0][0]);
    } else {
      $rows[$count][8] = str_replace("Compatible", "compatible", $rows[$count][8]);
      $rows[$count][8] = explode("compatible", $rows[$count][8]);
      //$rows[$count][8] = explode("Compatible", $rows[$count][8]); produces error if  used
      $rows[$count][8] = explode("-", $rows[$count][8][0]);
    }
    $countif = 1;
    while (isset($rows[$count][8][1][0][$countif])) {
      $countif++;
    }
    $max = $countif - 2;
    $countif = 9;
    $counter = 1;
    while ($max <= 5 && $max >= 1 && $countif <= 13) {
      $rows[$count][$countif] = $rows[$count][8][1][0][$counter];
      $countif++;
      $counter++;
    }
    $rows[$count][8][0] = explode("Compatible", $rows[$count][8][0]);
    //$rows[$count][8] = $rows[$count][8][0][0];

  }
  $count++;
}

print_r($rows[14][8]);

The problem is that even though ‘Compatible’ is in the string refered to in the explode statement it remains as a single string, un-exploded so to speak. the output is as below.

100% Brand New Made from high quality material to ensure good quality
Prevent Scratches bumps grease and finger prints on the screen You can
now easily use the mobile or text people with the stylus Designed to
be used with your touch screen mobile Compatible with: Nokia : 5530
Xpress MusicPackage Contents: 1 x Stylus for Nokia 5530 Xpress Music –
White

Any help is greatly appreciated.

EDIT: the var_dump($rows[14]);

0 => string '41807' (length=5)
  1 => string '' (length=0)
  2 => string 'http://images.esellerpro.com/2477/I/418/07/07_!B-dzTQ!BWk~$(KGrHqQOKnMEy1t9tWyLBM8tHiFEnQ~~0_1.JPG' (length=98)
  3 => string '' (length=0)
  4 => string '' (length=0)
  5 => string '' (length=0)
  6 => string '5055496500300    ' (length=17)
  7 => string 'STYLUS-5530-WHITE - STOCK CONTROL' (length=33)
  8 => string ' 100% Brand New Made from high quality material to ensure good quality Prevent Scratches bumps grease and finger prints on the screen You can now easily use the mobile or text people with the stylus Designed to be used with&nbsp;your touch screen mobile&nbsp;Compatible with:&nbsp;Nokia : 5530 Xpress MusicPackage Contents: 1&nbsp;x Stylus for Nokia 5530 Xpress Music -&nbsp;White&nbsp;' (length=386)
  9 => string '' (length=0)
  10 => string '' (length=0)
  11 => string '' (length=0)
  12 => string '' (length=0)
  13 => string '' (length=0)
  14 => string '-1' (length=2)
  15 => string '' (length=0)
  16 => string '' (length=0)
  17 => string 'Frooition' (length=9)
  18 => string '' (length=0)

EDIT2: Original Line:

3PREPAY-ZTEMF627W1GB        http://images.esellerpro.com/2477/I/217/94/03_!B8Zel8w!2k~$(KGrHqJ!hYEyrrVkKNYBM28dwn4o!~~0_1.JPG               5.0555E+12  ZTE MF627 THREE PAY BROADBAND USB MODEM WITH 1GB READY  New ZTE MF627 on Three Pay Broadband with 1GB allowance IncludedGet broadband speeds with no wires or hassles. Just plug this lightweight USB Modem into your laptop and watch as everything auto-installs whether you’re on Windows or Mac. Easy. The user friendly dashboard is also a breeze (so you don’t need any technical knowledge) and it lets you send and receive text messages while you’re online.The MF627 gives you download speeds of up to 3.6 Mbps. Plus you can use your new best friend as a memory stick just add a MicroSD card to the slot and load up to 4GB. And don’t ever worry about losing the lid because it’s connected with a handy strap! Compatible with: Most Desktops and Laptops (Also supports Windows 7 and Mac OS X 10.6)Packing Contents:1 X Brand New ZTE MF627 USB Model on Three Pay as you go Broadband  - 1GB Allowance Included Maximum 1 per customer please.                       -1          Frooition
  • 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-02T09:08:19+00:00Added an answer on June 2, 2026 at 9:08 am

    Here’s your problem..

    Its your second explode…

    $rows[$count][8][0] = explode("Compatible", $rows[$count][8][0]); 
    

    If the line doesn’t contain Features then $count[8] isn’t exploded and tunred into an array. In your var_dump $rows[$count][8] is just a string and $rows[$count][8][0] doesn’t exist. Change the line to do this..

    $rows[$count][8] = explode("Compatible", $rows[$count][8]);
    

    But you might want ot consider putting that in an else statement instead of changing it. Because the what you’ll have now will work IF the string contains Features and is exploded. So the line I’m suggesting should go in an Else statement incase Features isn’t apart of the string and $rows[$count][8] is never exploded.

    $rows;
    $count = 0;
    while (($row = fgetcsv($files, 56000)) !== false) {
      $rows[$count] = $row;
      if (stristr($rows[$count][8], "Features:")) {
        $rows[$count][8] = str_replace("Features:", "features", $rows[$count][8]);
        $rows[$count][8] = str_replace(":", "", $rows[$count][8]);
        $rows[$count][8] = explode("features", $rows[$count][8]);
        if (isset($rows[$count][8][1])) {
          $rows[$count][8][1] = str_replace("Compatible", "compatible", $rows[$count][8][1]);
          $rows[$count][8][1] = explode("compatible", $rows[$count][8][1]);
          //$rows[$count][8][1] = explode("Compatible", $rows[$count][8][1]); produces error if  used
          $rows[$count][8][1][0] = explode("-", $rows[$count][8][1][0]);
        } else if (isset($rows[$count][8][0])) {
          $rows[$count][8][0] = str_replace("Compatible", "compatible", $rows[$count][8][0]);
          $rows[$count][8][0] = explode("compatible", $rows[$count][8][0]);
          //$rows[$count][8][0] = explode("Compatible", $rows[$count][8][0]); produces error if  used
          $rows[$count][8][0][0] = explode("-", $rows[$count][8][0][0]);
        } else {
          $rows[$count][8] = str_replace("Compatible", "compatible", $rows[$count][8]);
          $rows[$count][8] = explode("compatible", $rows[$count][8]);
          //$rows[$count][8] = explode("Compatible", $rows[$count][8]); produces error if  used
          $rows[$count][8] = explode("-", $rows[$count][8][0]);
        }
        $countif = 1;
        while (isset($rows[$count][8][1][0][$countif])) {
          $countif++;
        }
        $max = $countif - 2;
        $countif = 9;
        $counter = 1;
        while ($max <= 5 && $max >= 1 && $countif <= 13) {
          $rows[$count][$countif] = $rows[$count][8][1][0][$counter];
          $countif++;
          $counter++;
        }
        $rows[$count][8][0] = explode("Compatible", $rows[$count][8][0]);
        //$rows[$count][8] = $rows[$count][8][0][0];
    
      }
      else // THE STRING DOESN'T CONTAIN "Features"
      {
            $rows[$count][8] = explode("Compatible", $rows[$count][8]);
      }
      $count++;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a flat CSV file which I need read from to end up
I have a CSV file, and a XSD from which I need to create
Possible Duplicate: Prepend lines to file in Java I have a CSV-file which supports
I have a csv file from which I have to populate different tables in
I have a PHP app that creates a CSV file which is forced to
I have .zip file which contain csv data. I am reading .zip file using
I have unpredictable frequency of Incoming csv data file which I need to store
I have a CSV file with many rows in which I need to update/replace
I have the following code snippet, which loads data from a CSV file into
I am using PHP to expose vehicle GPS data from a CSV file. This

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.