Page 1 of 1

exec loop

Posted: Mon Mar 21, 2011 9:52 am
by zizzu
Hello i am trying to execute a linux program for every line of a textarea

Code: Select all

	$text = $_POST['links'];
	
	$text = htmlspecialchars($_POST['links']);
	$text = nl2br($text);
	
	foreach(explode("\n",$text) as $row)
	{
		$result = NULL;
		$command = 'the command';
		exec($command,&$result);
		echo $result[0]."<br>";
	}
but this always print the result for last line of text area :(
for example is there are 3 lines it print 2 blanks and 1 result...
whats wrong??

Re: exec loop

Posted: Mon Mar 21, 2011 8:49 pm
by Jonah Bron
For starters, remove the htmlspecialchars and nl2br. Those are not necessary in this case. If you use htmlspecialchars, do it on the result. Do you realize that what you're doing is extremely dangerous?