This non working prototype code is bothering me....fixed.
<?php
# considering t2.txt contains below two lines
#a c d f n z r
#granc dr ssdo and
#
$file_lines = file_get_contents('./t2.txt');
$split_by_line = explode("\n",$file_lines);
$circular = array();
foreach ($split_by_line as $line) {
$split_by_words = explode(' ',$line);
sort($split_by_words);
$circular = $split_by_words;
foreach($split_by_words as $word){
array_push($circular,array_shift($circular));
echo implode($circular," ") . "\n";
}
$split_by_words = null;
echo "\n";
}