I got a text file, i read it then i need to change the rows into columns and columns into rows.
the text file i got is like this:
Oct-12|2585|5828|589|382|4821
Oct-13|2450|1828|525|342|1821
Oct-14|3455|1528|545|482|1421
Oct-15|2455|1588|345|982|1482
Oct-16|2555|1582|576|122|1911
Oct-17|2585|1310|685|981|1761
how can i switch and save the result in other text file?
thanks
Rows into Columns and Columns into Rows?
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
rotate clockwise:
Code: Select all
for($x = 0; $x < count($data[0]); $x++) {
for($y = 0; $y < count($data); $y++) {
$new[$x][$y] = $data[$y][$x];
}
}now i got a big problem.
i can read all the row, but i can read data by data.
i read: $data1=Oct-12|2585|5828|589|382|4821
but i want to read:
$data1[1]=Oct-12
$data1[2]=2585
$data1[3]=5828
$data1[4]=589
$data1[5]=382
$data1[6]=4821
$data2[1]=Oct-13
... etc
how can i separate each data? with the data in order, i will just rotate clockwise.
any help, thanks
i can read all the row, but i can read data by data.
i read: $data1=Oct-12|2585|5828|589|382|4821
but i want to read:
$data1[1]=Oct-12
$data1[2]=2585
$data1[3]=5828
$data1[4]=589
$data1[5]=382
$data1[6]=4821
$data2[1]=Oct-13
... etc
how can i separate each data? with the data in order, i will just rotate clockwise.
any help, thanks
Code: Select all
$data1 = explode('|', $data1);