Re: Formatting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/25/2011 9:05 PM, Ethan Rosenberg wrote:
Dear list -

I have a program with the following statement: $out = system('ls -l',
$retval); The output is a string. How do I format the output to be in
the Linux format, that is in columns. I cannot think of a way to use
explode to do it.

Advice and comments, please.

Thanks

Ethan

MySQL 5.1 PHP 5.3.3-6 Linux [Debian (sid)]



Well, depends, are you running this in a browser or at the console?

If you are displaying this in a browser, you are probably seeing that browsers do not like \n (newlines)

If in a browser, you could:
1) Wrap your output in a <pre><?php echo $out; ?></pre> HTML tag
2) Use PHP's nl2br() to replace all newlines with "<br />" tags
3) Use PHP's header() function to tell the browser to display the output as plaintext. i.e. header('Content-Type: text/plain'); [1,2]

1 - Google "php header plain text"
2 - http://www.php.net/manual/en/function.header.php#92620

If in cli...  well, you wouldn't be having this problem... :)

Jim Lucas

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux