I think has to do with the fact that Top is a command that somehow uses terminal commands (that output being a cursor positioning command I think). I tried putting this code:
exec('TERM=linux top n 1',$top);
echo nl2br(implode("\n",$top));
But it would still not work. What finally did work which I just discovered was adding the b parameter (batch mode) to the top command:
exec('TERM=linux top b n 1',$top);
echo nl2br(implode("\n",$top));
Thanks anyway 🙂