user548219
user548219

Reputation: 38

Help me understand this PHP code

I am a PHP beginner.

When going through a PHP script I found:

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

I want to know what does (?i) mean ?

Upvotes: 1

Views: 68

Answers (2)

Umakant Patil
Umakant Patil

Reputation: 2308

The below line is finding matching pattern in $input string like ID=any number.

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

Example matching patterns are ID=2 id=34 Id=23

Upvotes: 1

codaddict
codaddict

Reputation: 455440

(?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))
                         ^

Upvotes: 2

Related Questions