使用PHPExcel验证上载的Excel文件数据的最佳方法

What would be the most efficient way of checking data contained in arrays

I want to validate in the following ways:

  1. if cell a and b are a string
  2. if cell c and d are numbers
  3. if cells are empty

Then how would it be best to catch errors and display them to the user?

I'm using codeigniter and the PHPExcel library

an example of where I'm currently at

    public function read_excel()            
    {
        $this->load->library('excel');
        $inputFileName = 'test.xlsx';
        /**  Identify the type of $inputFileName  **/
        $inputFileType = PHPExcel_IOFactory::identify($inputFileName);
        $objReader = PHPExcel_IOFactory::createReader($inputFileType);
        /**  Advise the Reader that we only want to load cell data  **/
        $objReader->setReadDataOnly(true);
        /**  Load $inputFileName to a PHPExcel Object  **/
        $objPHPExcel = $objReader->load($inputFileName);
        $sheet = $objPHPExcel->getSheet(0); 
        $highestRow = $sheet->getHighestRow(); 
        $highestColumn = $sheet->getHighestColumn();


        //  Loop through each row of the worksheet
        for ($row = 2; $row <= $highestRow; $row++){     //  Read a row of data into an array
            $rowData = $sheet->rangeToArray('A'.$row.':'.$highestColumn.$row,NULL,TRUE,FALSE);

            $cella = strtoupper($rowData[0][0]);
            $cellb = strtoupper($rowData[0][1]);
            $cellc = $rowData[0][2];
            $celld = $rowData[0][3];
        }


    }

To Answer my own question i eventually went with the below

                if (!isset($rowData[0][0],$rowData[0][1],$rowData[0][2])) {

                echo "error cells a-c are required.";
            }



            for ($i=0; $i <$columns ; $i++) { 
                switch ($rowData[0][$i]) {
                    case (is_numeric($rowData[0][$i])):
                        filter_var($rowData[0][$i],FILTER_SANITIZE_NUMBER_INT);
                        echo $rowData[0][$i];
                        echo "</br>";
                        break;
                    case (is_string($rowData[0][$i])):
                        $rowData[0][$i] = preg_replace("/[^A-Za-z0-9\-]/"," ",$rowData[0][$i]);
                        break;
                }

            }