dimanche 12 novembre 2017

Reading multiple data from one file, PHP

I have this text file that I want to read and check if the value is correct or not and then display in html file:

Audi, 2006
BMW, 2019    //date incorrect
Toyota, 2016
Frd, 2017    //name incorrect 

All I did till now is:

$handle = file('src/can.txt');
$data = array();      
//loop to get the value from handle                                                
foreach ($handle as $key ) { 
  array_push($data, $key);
}

I wanted to continue using another loop where I create 2 array and then using explode method to separate the name of the car from the year of production.

My question is: is there any build in php method or any better way to perform the same operation?




Aucun commentaire:

Enregistrer un commentaire