I am in doubt that I can read a .txt
file and store its data in different positions in a array
.
The file is saved as follows:
city=A(100,80);
city=B(160,70);
city=C(110,50);
city=D(140,120);
city=F(155,40);
city=G(210,60);
city=H(190,10);
city=I(170,110);
route=A-C;140;
route=A-D;155;
route=C-F;125;
route=D-B;115;
route=D-I;152;
route=B-F;119;
route=B-G;136;
route=G-F;133;
route=F-H;163;
route=I-H;197;
And I would like to read it and store it separately in the positions of a array
.
<?php
$f = fopen("mapa.txt", "r");
while (!feof($f)) {
$arrM = explode(";",fgets($f));
}
fclose($f);
?>
In this example, it is storing it all within a single position! And in case I would like it to be stored like this:
$arrM[0] = city=A(100,80);
$arrM[1] = city=B(160,70);
$arrM[2] = city=C(110,50);
//.....
$arrM[] = route=A-C;140;