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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:30:48+00:00 2026-06-10T13:30:48+00:00

i have this file that i want to open, a csv file, and i

  • 0

i have this file that i want to open, a csv file, and i want to escape the 1st and 4th value for each line of data, a data record represented by $i.

when i say data record i mean each data that is split by a comma i.e.

data1, data2, data3, data4 …. etc.

this is my solution so far:

while (($data = fgetcsv($file_opener, 1000, ",")) !== FALSE) {
          $num = count($data);

              for ($i=0; $i < $num; $i++) {
                // for each 2nd and 3rd value push to array
                 array_push($Ages, $data[$i]);
               // if 1st and fourth value do nothing.
              }

i hope this is not confusing, if you need clarification let me know, and i did check the php docs, i was trying to use the array_chunk and map methods, but i don’t know how to use them in this instance. thanks

  • 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-10T13:30:49+00:00Added an answer on June 10, 2026 at 1:30 pm

    Still not sure what you’re trying to achieve, but this script removes each 1st and 4th element from each 4-column group in a record.

    <?php
    while( false!==($record=getNextRow()) ) {
        foreach($record as $k=>$v) {
            $rpos = $k % 4;
            if ( 0==$rpos || 3==$rpos ) {
                unset($record[$k]);
            }
        }
        echo join(', ', $record), "\n";
    }
    
    function getNextRow() {
        // just boilerplate to make it a self-contained example
        // this would be plain fgetcsv in yor case
        static $source = array('1,2,3,4,5,6,7,8', 'a,b,c,d,e,f,g,h,i,j,k,l', 'I,II,III,IV,V,VI,VII,VIII','IX');
        list(,$r) = each($source);
        return $r ? str_getcsv($r) : false;
    }
    

    prints

    2, 3, 6, 7
    b, c, f, g, j, k
    II, III, VI, VII
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a CSV-like text file that has about 1000 lines. Between each record
I have a simple .csv file that has that I want to extract data
I have a text file that I want to send over the network, this
I have a file that contains this <!-- CordovaVersion --> I want to replace
I have a file hosting site that's using this script MFHS . I want
I have a csv file with 48 columns of data. I need to open
I have a CSV file that I want to make available for my Android
Ok so basically I have a csv file with different values. I want each
I have a CSV file that I want to read with Ruby and create
Ok, so I have this .htaccess file that contains this <IfModule mod_rewrite.c> RewriteEngine On

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.