TSORT using PHP

I have written a very simple PHP script to try to solve the TSORT problem. I wouldn’t be surprised at all if it timed out, but I don’t know why I’m getting a “Wrong Answer” message. Can anyone tell me why or provide sample data that will cause the script to fail?

$count = 0;
$input = fopen('php://stdin', "r");
$output = fopen('php://stdout',"w");
 
$line1 = trim(fgets($input));
$test_cases = $line1[0];
$arr = array();
 
while($count < $test_cases){
	$val = trim(fgets($input));
	array_push($arr, $val);        
	$count++;
}

sort($arr);

foreach($arr as $val)  {
	echo $val . "\n";
}

I am new to php . can you help me how to code in php for codechef probelms ?

Thats pretty weird, your code definitely works fine, I changed the input method of your code and now it shows tle as expected heres a link to that code http://www.codechef.com/viewsolution/2402643 . With your case the only possible culprit I could think of is line number 7 as you can see in http://ideone.com/8FHiPL

//