Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news2.arglkargh.de!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Arno Welzel Newsgroups: comp.lang.php Subject: Re: Regarding split text and match from data base Date: Fri, 22 Nov 2013 17:50:44 +0100 Lines: 67 Message-ID: <528F8B64.2000804@arnowelzel.de> References: <676203c7-7d21-4513-92d5-7a9111c2eaa6@googlegroups.com> <528F7980.4040500@arnowelzel.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: individual.net xcn3w4Eg1JWOcpNwjYNGLQYS97sfwnXbWfQi3rZ4GBlerIRgIn Cancel-Lock: sha1:G7yXZRS2bMUm5O9aRx611YfY+Ww= User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 In-Reply-To: X-Enigmail-Version: 1.6 Xref: csiph.com comp.lang.php:11929 Jerry Stuckle, 2013-11-22 16:54: > On 11/22/2013 10:34 AM, Arno Welzel wrote: >> Am 22.11.2013 12:28, schrieb jalaf28@gmail.com: >> >>> Hello All I just start learning PHP and i am using 5.4.16 i just >>> want to split the out put of the following and match from the >>> database and print the System name. >>> >>> here is the Code >>> >>> >> >>> ob_start(); $line=shell_exec("arp -a"); echo "
; echo $line; echo
>>> "
"; >>> >>> ?> >>> >>> It shows the output of the command "arp -a" and show the Ip address >>> and Mac address on the LAN system. i saved the name and the Mac >>> address in the database. now i want to extaxct the command output and >>> match ["MAc address] with database and show the Particular system >>> name and Ip Address. i try google but not sufficent. >> >> You can try explode() using space (' ') as delimiter, see: >> >> >> >> >> > > Arno, > > Have you actually looked at the output of arp -a? From your response, I > don't think so. And where is your answer to the question? Anyway... arp -a outputs here (numbers as "x" for privacy reasons): somename (xxx.xxx.xxx.xxx) at xx:xx:xx:xx:xx:xx [ether] on eth0 So - using explode() on this line with space as delimiter should return an array with the following elements: somename (xxx.xxx.xxx.xxx) at xx:xx:xx:xx:xx:xx [ether] on eth0 Then you can use the fourth element which contains the MAC address. If you get more than one line of output, the lines have to be split first of course. Therefore I'd recommend using exec() which will return the output as an array with one element for each line of output. -- Arno Welzel http://arnowelzel.de http://de-rec-fahrrad.de