Split and Explode problem.
| From: | QCS) | Date: | Mon, 10 Jul 2000 09:52:40 +0000 |
| Subject: | Split and Explode problem. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-5702@lists.php.net to get a copy of this message | ||
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!