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!
1 Answer
$contents = file($path);
foreach($contents as &$row){
$row = explode(",",$row);
}
file() reads the file into an array, one line is one array element.
4 Comments
Martin
It's not what I am looking for could you look at the topic again? Thanks for your reply!
Viktor Koncsek
This is exactly what you said you want.
Martin
Not exactly, because now I have array with rows of the file and I also need to list the column of the rows like in picture above.
Martin
Okay I've solved it out, with your code but a little bit editing it. Thanks!


$contents = file_get_contents($path); $pollfields = explode(',', $contents); echo '<pre>'; print_r($pollfields); echo '</pre>';