How do I import PHPExcel files into arrays (select the specified columns)?

  question

Use phpexcel to import into an array, but currently the specified column cannot be selected for import (currently all columns will be imported). Would you like to import only the data of column A and column C to solve?


The following code output effect
图片描述

<?  Php
 header("Content-Type:text/html;  charset=utf-8");
 $dir=dirname(__FILE__);  //Find the path where the current script is located
 
 require $dir."/PHPExcel/PHPExcel/IOFactory.php";  //Introduce class files for reading excel
 $filename=$dir."/lang.xlsx";
 
 $fileType=PHPExcel_IOFactory::identify($filename);  //The type of automatically obtained file is provided to phpexcel
 $objReader=PHPExcel_IOFactory::createReader($fileType);  //Get the file read operation object
 $objReader->setLoadSheetsOnly($sheetName);  //Load only the specified sheet
 $objPHPExcel=$objReader->load($filename);  //load file
 $sheetCount=$objPHPExcel->getSheetCount();  //How many sheet are there in inside to obtain excel files
 
 Foreach ($ objphpexcel-> getworksheetitor () as $ sheet) {//loop sheet
 
 Foreach ($ sheet-> getrow iterator () as $ row) {//process line by line
 
 if($row->getRowIndex()<2){
 continue;
 bracket
 Foreach ($ row-> getcellerator () as $ cell) {//read column by column
 
 $data=$cell->getValue();  //Get Cell Data
 echo $data." ";
 
 bracket
 echo '<br/>';
 bracket
 echo '<br/>';
 bracket
 exit;
 ?  >

At present, the data format of excel is as follows. How to import into the effect of Figure 2?
Figure (1)
图片描述

Figure (2)
图片描述

After traversing, re-assign the value once.