exec() incomplete $output

Using Ubuntu 5, Apache2 and PHP 4 I am trying display in a web browser
the output from a program I wrote in C.

Here is an abridged version of my code (I can post all of it later):


exec( "myProg -a paramA -b paramB", $output);

print "<p>Returned: $return</p>";

foreach ( $output as $val ) {
print "$val<br />";


The problem is that in the web browser only the first two lines of the
$output appear when there should almost always more than that (usually
around 10).

I have done a test with php CLI using the same code as above: php -f
mycode. The right/expected ouput comes out here.

Any ideas how this different behaviour might be happening? Wondering if
there is some default limit on the number of lines displayed by php in
the browser... or if the actual lines are too long (but 100 chars isn't
too much is it?). Thanks.