Helo,
> I meant explode each *line* (at the EOL character(s)), so this:
> xxx.x.x.x | 0.0.0.0 255.255.255.255 UH 0 | | | 0 | | | | 0 ppp0
> is an element of the array. And this:
> 192.168.0.0 0.0.0.0 255.255.255.0 U | | 0 | | | 0 | | | | 0 eth1
> is another element, etc.
> > 0.0.0.0 | | xxx.x.x.x 0.0.0.0 | | UG | 0 | | | 0 | | | | 0
> > E.g. Line 3 won't be in an array. This could maybe be caused from
> > drop & paste to copy from a shell into the browser while using
> > an extraordinary OS.
> Then you can process each line separately but in groups 3 lines at a time
> (assuming they're supposed to be groups of 3).
but what happen's in the case a user drop down every line in a web
form without a ELO character ?
> > The difference lead's now to an error as the syntax is wrong.
> If you state clearly, in detail, what exactly you want the regex
> to match then
> maybe someone could construct a better one for you.
Ok, at the moment I verify the assuming missed device with a difference
of the following both block's:
<?
$INET_NUM_exp = ereg_replace("[\ ]+([a-z]+)([0-9]{1})","\\1\\2_XrR",$INET_NUM);
$sorter = explode("_XrR",$INET_NUM_exp);
$result = count($sorter);
$result = $result-1;
$INET_NUM_exp2 =
ereg_replace("([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})[\
]+([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})[\
]+([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})[\
]+","\\1\\2_XrR",$INET_NUM);
$sorter2 = explode("_XrR",$INET_NUM_exp2);
$result2 = count($sorter2);
$result2 = $result2-1;
?>
In the case $result is equal to $result2 the following code
will be called within a function. If not an error occurs which
will lead to a exit before the following is done.
<?
if ($INET_NUM && ereg('[\ ]+([a-z]+)([0-9]{1})',$INET_NUM,$part)) {
$INET_STRING = $part[1].$part[2];
$INET_NUM = ereg_replace("[\
]+([a-z]+)([0-9]{1})","\\1\\2_XrR",$INET_NUM);
$sorter = explode("_XrR",$INET_NUM);
array_pop($sorter);
while(list($key,$value) = each($sorter)) {
if (ereg('([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})[\
]+([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})[\
]+([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})[\ ]+([A-Z]+)[\
]+([0-9]+)[\ ]+([0-9]+)[\ ]+([0-9]+)', $value, $part)) {
if ($part[1] <= 255 && $part[2] <= 255 && $part[3] <= 255 &&
$part[4] <= 255 && $part[5] <= 255 && $part[6] <= 255 && $part[7] <= 255 &&
$part[8] <= 255 && $part[9] <= 255 && $part[10] <= 255 && $part[11] <= 255 &&
$part[12] <= 255 && is_numeric($part[1]) && is_numeric($part[2]) &&
is_numeric($part[3]) && is_numeric($part[4]) && is_numeric($part[5]) &&
is_numeric($part[6]) && is_numeric($part[7]) && is_numeric($part[8]) &&
is_numeric($part[9]) && is_numeric($part[10]) && is_numeric($part[11]) &&
is_numeric($part[12])){
$value = clean_sql_output($value);
$value = str_replace("\\r\\n","<br>",$value);
$INET_NUM_array[$i] = $value;
$i++;
} else {
$stat_ip_address_is_not_valid++;
}
} else {
$stat_ip_address_is_not_valid++;
}
}
} else {
$stat_ip_address_is_not_valid++;
}
if ($stat_ip_address_is_not_valid<1) { return $INET_NUM_array;}
$INET_NUM_array[0] = 0;
return $INET_NUM_array; ### SYNTAX ERROR ##
}
?>
--
Best Regards,
Mark
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php