Explore topic-wise MCQs in PHP Questions & Answers Introduction to Preg in PHP.

This section includes 2 Mcqs, each offering curated multiple-choice questions to sharpen your PHP Questions & Answers Introduction to Preg in PHP knowledge and support exam preparation. Choose a topic below to get started.

1.

Which one of the following functions are used to search a string?

A. preg_match
B. preg_search
C. preg_find
D. preg_found
Answer» B. preg_search
2.

What will be the output if we replace the line $num = preg_grep( /[0-5]/ , $number); with $num = preg_grep( /[0-5]/ , $number, PREG_GREP_INVERT);?

A. Array([0]=>0 [1]=>1 [2]=>two [3]=>three [4]=>four [5]=>5)
B. Array([2]=>two [3]=>three [4]=>four)
C. Array([1]=> 1)
D. Array([0]=>0 [5]=>5)
Answer» C. Array([1]=> 1)