RE: [PHP] Split and Explode problem.

From: Date: Mon, 10 Jul 2000 11:37:21 +0000
Subject: RE: [PHP] Split and Explode problem.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-5709@lists.php.net to get a copy of this message
Looking at the output from the 'w' command it seems the output uses fixed length columns. I would chop it up into substrings, do a trim and place it in the array. Dan Sevush CTO Dan's Chocolates www.danschocolates.com [Serving millions of PHP generated pages since November '99] > -----Original Message----- > From: Joachim Holst (QCS) [mailto:Joachim.Holst@ecs.ericsson.se] > Sent: Monday, July 10, 2000 5:53 AM > To: Php-List (E-mail) > Subject: [PHP] Split and Explode problem. > > > 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 >

« previous php.general (#5709) next »