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!
If you want to copy only a small first portion of the column, this must be efficient:
This leaves only name and surname in the matrix: