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

  • Home
  • SEARCH
  • 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 9156317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:44:52+00:00 2026-06-17T12:44:52+00:00

I am extracting data from an xls document which returns as an array. The

  • 0

I am extracting data from an xls document which returns as an array. The array keys however is not numeric, but resembles the cell column alphabetical digit. So effectively I have an array like this:

  // Example array:
  $array = array(
        [0] => array(
              "A" => "Name",
              "B" => "Surname",
              "C" => "",
              "D" => "Telephone"
        ),
        [1] => array(
              "A" => "Name",
              "B" => "Surname",
              "C" => "",
              "D" => "Telephone"
        ),
        [2] => array(
              "A" => "",
              "B" => "",
              "C" => "",
              "D" => ""
        )
  );

Now the problem with the returned array is it does not filter the array at all, and I may have rows and rows of empty values in the rows.

I need a way to either clean up the array completely so remove empty rows and digits, but this may give me some issues with array consistancy later.

What I am looking for is a function which can chop rows in an array by a alphebitical digit. So effectively something like array_chop($array”,”C”); which would then effectively unset all the remainder rows key and value pairs from D onwards.

Is this possible? Is there a php function already I can use? I am sorry that I cannot provide sample code but I have no idea where to start. The array is substancially large, so I am looking for a memory efficient solution.

Thank you in advance!

  • 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-17T12:44:53+00:00Added an answer on June 17, 2026 at 12:44 pm

    If you want to copy only a small first portion of the column, this must be efficient:

    <?php
    $array = array(
          0 => array(
                "A" => "Name",
                "B" => "Surname",
                "C" => "",
                "D" => "Telephone"
                ),
          1 => array(
                "A" => "Name",
                "B" => "Surname",
                "C" => "",
                "D" => "Telephone"
                ),
          2 => array(
                "A" => "",
                "B" => "",
                "C" => "",
                "D" => ""
                )
          );
    
    $last_column = 1;
    
    $n = count($array);
    for ($i = 0; $i < $n; ++$i)
    {
          $copy = array();
          $j = 0;
          foreach($array[$i] as $key => $value)
          {
                if ($j <= $last_column)
                {
                      $copy[$key] = $value;
                     ++$j;
                }
                else
                {
                      $array[$i] = $copy;
                      break;
                }
          }
    }
    
    var_dump($array);
    

    This leaves only name and surname in the matrix:

    array(3) {
      [0]=>
      array(2) {
        ["A"]=>
        string(4) "Name"
        ["B"]=>
        string(7) "Surname"
      }
      [1]=>
      array(2) {
        ["A"]=>
        string(4) "Name"
        ["B"]=>
        string(7) "Surname"
      }
      [2]=>
      array(2) {
        ["A"]=>
        string(0) ""
        ["B"]=>
        string(0) ""
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am running a package which is extracting data from a single flat file
I'm struggle extracting necessary data from this json stored inside php variable. Not yet
I am currently designing a correlation engine in java which is extracting data from
I'm learning iOS but have an issue extracting data from a multidimensional NSMutableArray ,
Hi I'm having trouble extracting data from this XML document. <messages messageCount=6> <message messageID=9999
I am having trouble extracting data from the following function which only works with
I'm working on extracting data from a SQL Server database with a latin_1 character
struggle extracting necessary data from this complex json stored inside php variable. Via php
I am extracting a column of data from a range of filenames. All my
I am tasked with extracting data from 2 tables: Master and Charges. The common

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.