DataSpy Posted March 19, 2012 Share Posted March 19, 2012 This is my first time using preg_match and I'm a little confuesed I'm trying to match an array against zero but I keep getting the error: Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in $IP = implode('.',$Start); $Command = shell_exec("ping -c 1 -w 1 $IP"); $data = explode(',',$Command); $data = $data[1]; if(preg_match("0", '$data')) { echo "$IP online <br />"; } any help would be greatly apprenticed, thanks in advance!!! Quote Link to comment Share on other sites More sharing options...
requinix Posted March 19, 2012 Share Posted March 19, 2012 It doesn't sound like you should be using regular expressions. What do you mean "match an array against zero"? Quote Link to comment Share on other sites More sharing options...
abareplace Posted March 19, 2012 Share Posted March 19, 2012 1) Is ping output separated with commas? 2) If you need to compare the second element of the array with "0", just write if ($data[1] == '0'). No regular expression is needed. Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted March 19, 2012 Share Posted March 19, 2012 You are getting the error because you aren't using delimiters at all, read preg_match And yeah, you don't need regex for this. Quote Link to comment Share on other sites More sharing options...
DataSpy Posted March 19, 2012 Author Share Posted March 19, 2012 Thanks for all of the replies!!! I used if () instead, sorry about being a dumbass . I was looking at an example of something but I changed a lot of code and in the end didn't need to use preg_match. Thanks!!!!!!!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.