This is the spreadsheet:
Thisisthecode:
publicfunctionloadExcel($file,$dir){$objReader=PHPExcel_IOFactory::createReader('Excel2007');$filterValidation=newApplication_Model_Filter_FilterValidation();if(file_exists($dir.DS.$file)){$objPHPExcel=$objReader->load($dir.DS.$file);$arrayData=array();//laço1foreach($objPHPExcel->getWorksheetIterator()as$worksheet){$arrayData[$worksheet->getTitle()]=$worksheet->toArray(null,true,true,true);}$sheetData=array_values($arrayData)[0];$header=$sheetData[1];unset($sheetData[1]);$data=array_values($sheetData);//return$data;if(count($data)){$result=array();//laço2foreach($dataas$key=>$value){if(count($value)){//laço3foreach($valueas$letter=>$val){if($header[$letter]!=''&&!is_null($header[$letter])&&!is_numeric($header[$letter])){if(!is_null($val)){$result[$header[$letter]][]=$val;}}}}}$new=array();//laço4foreach($resultas$key=>$val){if(count($val)){//laço5foreach($valas$idx=>$dado){if(count($dado)){$new[$idx][$key]=$dado;}}}}return$new;}}}
Result:
Array([0]=>Array([NOME]=>LuizFelipeMachado[USUARIO]=>alunoguten001[SENHA]=>aluno001)[1]=>Array([NOME]=>MariaRitadeCássia[USUARIO]=>alunoguten002[SENHA]=>aluno002))
PS:partofthissolutionhasbeenresolved this question , but I do not think it is necessary to make three foreach to handle the data, I believe that it is possible to improve this in a single loop, how could it improve?