Jump to content

String manipulation.


sepoto

Recommended Posts

I have a string like this:$c = $_SERVER["REMOTE_ADDR"];So in memory the string actually looks in human form like this "192.168.1.1".What I want to do is create an if something in pseudo code like this:if($c == "192.168.%.%") { //Where % is wildcard could be anything at all Ignore it};How could I go about accomplishing a task like this?Thanks!

Link to comment
Share on other sites

That's what regular expressions are for.You can use preg_match for it:

if(preg_match('/192\.168\.\d{0,3}\.\d{0,3}/',$c)) {  // Ignore}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...