Hello, I got some problems for eregi function, Please Help me Correcting the Following Code, and tell me how should it be to work properly, [COLOR=#999988][I]// check the domain validity:[/I][/COLOR] [B]if[/B]([B]![/B][COLOR=#0086B3]eregi[/COLOR]([COLOR=#DD1144]'^[a-zA-Z0-9\-]{1,}$'[/COLOR], [COLOR=#008080]$domain[/COLOR])) [B]return[/B] [B]false[/B]; [B]if[/B]([COLOR=#0086B3]eregi[/COLOR]([COLOR=#DD1144]'[-]{2,}'[/COLOR], [COLOR=#008080]$domain[/COLOR])) [B]return[/B] [B]false[/B]; [B]if[/B]([COLOR=#0086B3]eregi[/COLOR]([COLOR=#DD1144]'^[-]{1,}'[/COLOR], [COLOR=#008080]$domain[/COLOR])) [B]return[/B] [B]false[/B]; [B]if[/B]([COLOR=#0086B3]eregi[/COLOR]([COLOR=#DD1144]'[-]{1,}$'[/COLOR], [COLOR=#008080]$domain[/COLOR])) [B]return[/B] [B]false[/B]; [COLOR=#008080]$data[/COLOR] [B]=[/B] [COLOR=#008080]$this[/COLOR][B]->[/B][COLOR=#008080]whois[/COLOR]([COLOR=#008080]$tld_array[/COLOR][[COLOR=#DD1144]"whois_server"[/COLOR]],[COLOR=#008080]$domain[/COLOR] [B].[/B] [COLOR=#DD1144]'.'[/COLOR] [B].[/B] [COLOR=#008080]$tld[/COLOR]); [B]if[/B]([B]![/B][COLOR=#008080]$data[/COLOR]) [B]return[/B] [B]false[/B]; [B]if[/B]([COLOR=#0086B3]eregi[/COLOR]([COLOR=#008080]$tld_array[/COLOR][[COLOR=#DD1144]"avail_response"[/COLOR]], [COLOR=#008080]$data[/COLOR])) [B]return[/B] [B]true[/B]; [B]else[/B] [B]return[/B] [B]false[/B]; [B]return[/B] [B]false[/B]; } Code (markup): Thanks in advance, Please Help
eregi is deprecated as of PHP 5.3 use preg_match instead. Shouldn't be that hard to rewrite. http://at.php.net/manual/en/function.preg-match.php Code (markup):
Can you please Re-Write the Code for me with the change of eregi to preg-match, please let me know how it should be to work, as i had several trials but failed to put it working properly Thanks
If Im able to do it myself, I wouldnt asking for help in this forum, anyways thank you, i think that i will get more help from someone who appreciate helping others Thanks !!!
You know the proverb: Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime. I'll throw in a good PHP tutorial http://devzone.zend.com/6/php-101-php-for-the-absolute-beginner/ http://tut.php-quake.net/en/post.html Code (markup): and a regular expression tutorial http://www.zytrax.com/tech/web/regex.htm Code (markup): With these you should be able to fish
If you read the documentation for preg_match, there shouldn't have much difference. It should look something like this in preg_match: if(!preg_match('/^[a-zA-Z0-9\-]{1,}$/', $domain)) return false; if(preg_match('/[-]{2,}/', $domain)) return false; if(preg_match('/^[-]{1,}/', $domain)) return false; if(preg_match('/[-]{1,}$/', $domain)) return false; PHP: