php - Sort the contents of the textfile in ascending -


i trying develop code sort contents of text file in ascending order. have read contents of file , able display texts. having difficulty sorting them out in low high order, word word.

i have tried asort php.net, not code work well. thanks.

to answer second question, can read text file into variable (like you've said have already), eg. $variable, use explode (http://php.net/manual/en/function.explode.php) separate, @ each space, each word array:

//$variable content text file $output = explode(" ",$variable); //explode content @ each space  //loop through resulting array , output ($counter=0; $counter < count($output); $counter++) {     echo $output[$counter] . "<br/>"; //output screen line break after each  } //end loop 

if paragraph contains commas etc don't want output can replace in variable before exploding it.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -