Re: how to parse a string parse with ereg

From: Date: Wed, 17 Nov 2004 04:55:48 +0000
Subject: Re: how to parse a string parse with ereg
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-202271@lists.php.net to get a copy of this message
On Wednesday 17 November 2004 07:17, Mark-Walter@t-online.de wrote: > But it has one weakness. In the case the device (ppp0) is > missing somewhere in the output as the user didn't intend > to integrate this required information, and by having insight > it could be more than 10 lines with 10.000 rules of > netfilter, explode will show concerning this example of 3 > lines 2 defined arrays and it won't lead to an error as > explode doesn't give a return value back which > has not been proofed to be exploded with _XrR. > > As I want to proof the syntax of all lines this is > wrong and not usable. I have to admit I'm not following you. My suggestion that you use explode() was based on the premise that you have a bunch of lines: ... xxx.x.x.x   0.0.0.0 255.255.255.255 UH 0      0        0 ppp0 192.168.0.0 0.0.0.0 255.255.255.0 U    0      0        0 eth1 0.0.0.0     xxx.x.x.x 0.0.0.0     UG   0      0        0 ppp0 ... that are currently stored in a string. After explode() you can use foreach() to loop through the array and check each line individually. Then based on whether the line passes the check you could either: a) unset that array element (doesn't pass check so get rid of it) or b) copy that element to a new array (passes check so store it in a 'good' array) Either way you'll end up with an array containing only 'good' lines. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * ------------------------------------------ Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general ------------------------------------------ /* Microsoft broke Volkswagen's world record: Volkswagen only made 22 million bugs! */

« previous php.general (#202271) next »