I've got a multi-dimensional array with an array element containing a long text string.
I need to match a number that represents particular syslog events within the text string eg. 106023. There are about 30 different codes that I want to look for and only one code will appear in each array element.
I thought that using a switch conditional would be the best way to do this but I can't seem ot match the string when doing this.
My code looks like this:
<?
for ($row; $row<$_SESSION['n1']; $row++) {
switch ($querydata[$row]['MsgText']){
case eregi ('106023', $querydata[$row]['MsgText']):
.....some operations....
break;
}
}
?>
The code works when using if statements but I want to use a switch because its more efficient.
What am I doing wrong?
I need to match a number that represents particular syslog events within the text string eg. 106023. There are about 30 different codes that I want to look for and only one code will appear in each array element.
I thought that using a switch conditional would be the best way to do this but I can't seem ot match the string when doing this.
My code looks like this:
<?
for ($row; $row<$_SESSION['n1']; $row++) {
switch ($querydata[$row]['MsgText']){
case eregi ('106023', $querydata[$row]['MsgText']):
.....some operations....
break;
}
}
?>
The code works when using if statements but I want to use a switch because its more efficient.
What am I doing wrong?