Re: Array Question

From: Date: Mon, 26 Apr 2004 14:28:51 +0000
Subject: Re: Array Question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-184653@lists.php.net to get a copy of this message
From: "Ian Barnes" <ian@cerebellum.za.net> > Here is what I have done so far: > > <?php > exec('netstat -na', $sts); //Runs the Netstat Command > unset ($sts[0]); //Removes the first line (Headings) > unset ($sts[1]); //Removes the second line (Arb Info) > > $sts=preg_replace('/ +/', ',', $sts); //Removes white spaces and replaces > with commas > ?> > > This is a typical output of a netstat -na: (Note the top two lines of this > where removed using unset). > > Active Internet connections (including servers) > Proto Recv-Q Send-Q Local Address Foreign Address (state) > tcp4 0 0 192.168.5.1.3128 192.168.5.222.1052 TIME_WAIT > udp4 0 0 *.514 *.* > Active UNIX domain sockets > Address Type Recv-Q Send-Q Inode Conn Refs Nextref Addr > c83a6640 stream 0 0 c83935c0 0 0 0 > /tmp/screens/S-root/887.ttyp4.comrite-mdb Try using array_search() to look for the element that has a value of 'Active UNIX domain sockets. Then, elements 2 through $x-1 are the first part your after and elements $x+1 through count($sts) are the second part. Actually, it looks like you'll have to search for 'Active,UNIX,domain,sockets' since you're removing whitespace. ---John Holmes...

« previous php.general (#184653) next »