Re: Split and Explode problem.
| From: | phpmail at mulder dot alps dot org | Date: | Mon, 10 Jul 2000 17:25:20 +0000 |
| Subject: | Re: Split and Explode problem. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-5764@lists.php.net to get a copy of this message | ||
spit out $result line by line in a loop in between <pre> tags
echo "<pre>";
for($i=0; $i<sizeof($result); $i++)
echo "$result[$i]<br>";
echo "</pre>";
On Mon, 10 Jul 2000, Joachim Holst (QCS) wrote:
> Hi !
>
> I'm trying to create a page that will display system information about my server.
> Thought it would be quite cool to display such info and a good place to start
> getting aquianted with PHP.
> I'm now busy trying to display what users are logged on to the system (I know not good
> for security reasons but the computer isn't world connected). For this I'm using
> the "exec("/usr/sbin/w",$arr,$result);" command. This stores the
> information that "w" prints
> in an array. The problem is that the text printed by "w" sin't that web
> friendly. So I thought that I
> could format the text myself and print it in a table.
> Looking around in the PHP manual, I found explode and split. These are quite cool
> functions, but I have a little problem with them. The "w" command is keen on using
> " " chars
> for displaying text and using explode, that gets me an array with about 36 entries in it when
> all I need is 8.
> I tried with the split function with the "[A-Za-z0-9@\t] " to get the info I wanted.
> This did of course work, but
> the last character of each word was also lost :-(
> Is there an easy way to get what I want or will I have to manually step through eac string and
> create my own
> array of values ??
>
> /Jocke!
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>