phpregexpreg-match

What does (?i) mean?


When going through a PHP script I found:

if(preg_match('/(?i)ID=(\d+)/',$input)) {
    // id found
}

I want to know what (?i) means.


Solution

  • (?i) is a in line modifier which makes the match case insensitive.

    It is equivalent to adding a i after the closing delimiter:

    if(preg_match('/ID=(\d+)/i',$input))
                             ^