SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    966
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Please help me with ereg

    Hello,

    ereg is diprecated. so please help me to replace ereg in below code.

    Code:
    	$answer=true;
    	$arr = array
    	("select","union","order","by","update","drop","use","group","by","insert","load_file","into","in","to","outfile","having","substr","hex","unhex","where","--","/","\'","\"");
    	 for($i=0;$i<sizeof($arr);$i++)
    	 {
    		 if(ereg($arr[$i],strtolower($str))){
    				 $answer=false;
    		 }
    	 }

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,196
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Give this a whirl

    PHP Code:
    $answer true;
    $arr    = array("select","union","order","by","update","drop","use","group","by","insert","load_file","into","in","to","outfile","having","substr","hex","unhex","where","--","\/","\'","\"");

    for(
    $i 0$i sizeof($arr); $i++) {
        if (
    preg_match('/' $arr[$i] . '/'strtolower($str))) {
            
    $answer false;
        }


  3. #3
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    966
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by chris.upjohn View Post
    Give this a whirl

    PHP Code:
    $answer true;
    $arr    = array("select","union","order","by","update","drop","use","group","by","insert","load_file","into","in","to","outfile","having","substr","hex","unhex","where","--","\/","\'","\"");

    for(
    $i 0$i sizeof($arr); $i++) {
        if (
    preg_match('/' $arr[$i] . '/'strtolower($str))) {
            
    $answer false;
        }

    thanks buddy,
    works charm!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •