southbeach
Programmer
OK - Working on a dashboard where text content is read and displayed in full or based on sorting/search criteria. Not a problem! Thus far I have written the code to do all that. I have the code to
(a) loop through a directory and identify .txt files
(b) read each .txt files and append it to an array - Thank goodness for array_merge()!
(c) push loaded content
Now that I am able to do all that, requests start to pour in. I now need to sort ASC or DES on any of the text columns.
Problem:
.txt files are more like flat csv documents or text files where columns are separated by commas so, a typical row may look like this: AAA,BBB,CCC,DDD,EEE,FFF,GGG,HHH,III,JJJ,KKK,LLL,MMM,NNN,OOO,PPP,QQQ ...
The array if dumped may look like:
Array(
[0]=>AAA,BBB,CCC,DDD,EEE,FFF,GGG,HHH,III,JJJ,KKK,LLL,MMM,NNN,OOO,PPP,QQQ
[1]=>AAA,BBB,CCC,DDD,EEE,FFF,GGG,HHH,III,JJJ,KKK,LLL,MMM,NNN,OOO,PPP,QQQ
[2]=>AAA,BBB,CCC,DDD,EEE,FFF,GGG,HHH,III,JJJ,KKK,LLL,MMM,NNN,OOO,PPP,QQQ
...
)
Obviously, each row is different from each other as you normally would expect. Given that the entire row goes into an individual array element, it seems that I cannot use PHP built in array sorting methods which brings me to
QUESTIONS:
(a) Am I mistaken that there is no way I could sort data content due to the way I am loading my data onto arrays?
(b) If (a), how then could I sort?
(c) Should I fix my code to load data into a multidimensional arrays? Can these arrays be sorted?
As usual, thank you all in advance for your assistance!
--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.
(a) loop through a directory and identify .txt files
(b) read each .txt files and append it to an array - Thank goodness for array_merge()!
(c) push loaded content
Now that I am able to do all that, requests start to pour in. I now need to sort ASC or DES on any of the text columns.
Problem:
.txt files are more like flat csv documents or text files where columns are separated by commas so, a typical row may look like this: AAA,BBB,CCC,DDD,EEE,FFF,GGG,HHH,III,JJJ,KKK,LLL,MMM,NNN,OOO,PPP,QQQ ...
The array if dumped may look like:
Array(
[0]=>AAA,BBB,CCC,DDD,EEE,FFF,GGG,HHH,III,JJJ,KKK,LLL,MMM,NNN,OOO,PPP,QQQ
[1]=>AAA,BBB,CCC,DDD,EEE,FFF,GGG,HHH,III,JJJ,KKK,LLL,MMM,NNN,OOO,PPP,QQQ
[2]=>AAA,BBB,CCC,DDD,EEE,FFF,GGG,HHH,III,JJJ,KKK,LLL,MMM,NNN,OOO,PPP,QQQ
...
)
Obviously, each row is different from each other as you normally would expect. Given that the entire row goes into an individual array element, it seems that I cannot use PHP built in array sorting methods which brings me to
QUESTIONS:
(a) Am I mistaken that there is no way I could sort data content due to the way I am loading my data onto arrays?
(b) If (a), how then could I sort?
(c) Should I fix my code to load data into a multidimensional arrays? Can these arrays be sorted?
As usual, thank you all in advance for your assistance!
--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.