Re: how to parse a string parse with ereg

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wednesday 17 November 2004 07:17, Mark-Walter@xxxxxxxxxxx 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!
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux