Martin
Martin

Reputation: 1279

Convert file to array and explode with comma

I would like to convert my rpt file to array. The file is divided with commas. Of course that's easy part. The second thing I need to convert it into multidimensional array, which probably is also easy but I got stuck in it. I need to make it that each line of the file will be next row.
I'm looking in my head but I don't know how to solve it.
I hope you'll help me!

enter image description here

enter image description here

Upvotes: 0

Views: 44

Answers (1)

Viktor Koncsek
Viktor Koncsek

Reputation: 574

$contents = file($path);
foreach($contents as &$row){
  $row = explode(",",$row);
}

file() reads the file into an array, one line is one array element.

Upvotes: 1

Related Questions