Q:
PHP find output programs (Regular Expressions) | set 1
belongs to collection: PHP Find Output Programs
PHP Find Output Programs
- PHP find output programs (basics) | set 1
- PHP find output programs (basics) | set 2
- PHP find output programs (basics) | set 3
- PHP find output programs (Superglobals) | set 1
- PHP find output programs (conditional statements) | set 1
- PHP find output programs (conditional statements) | set 2
- PHP find output programs (conditional statements) | set 3
- PHP find output programs (switch Statement) | set 1
- PHP find output programs (switch Statement) | set 2
- PHP find output programs (switch Statement) | set 3
- PHP find output programs (Operators) | set 1
- PHP find output programs (Operators) | set 2
- PHP find output programs (Operators) | set 3
- PHP find output programs (Loops) | set 1
- PHP find output programs (Loops) | set 2
- PHP find output programs (Loops) | set 3
- PHP find output programs (Loops) | set 4
- PHP find output programs (Arrays) | set 1
- PHP find output programs (Arrays) | set 2
- PHP find output programs (Arrays) | set 3
- PHP find output programs (User-defined functions) | set 1
- PHP find output programs (User-defined functions) | set 2
- PHP find output programs (User-defined functions) | set 3
- PHP find output programs (String Functions) | set 1
- PHP find output programs (String Functions) | set 2
- PHP find output programs (Number Functions) | set 1
- PHP find output programs (Math Functions) | set 1
- PHP find output programs (Math Functions) | set 2
- PHP find output programs (Date and Time) | set 1
- PHP find output programs (define Constant) | set 1
- PHP find output programs (static variables, classes, methods) | set 1
- PHP find output programs (static variables, classes, methods) | set 2
- PHP find output programs (Regular Expressions) | set 1
- PHP find output programs (Exceptions) | set 1
- PHP find output programs (Exceptions) | set 2
- PHP find output programs (Filters) | set 1
- PHP find output programs (Filters) | set 2
- PHP find output programs (JSON) | set 1
- PHP find output programs (const Keyword) | set 1
- PHP find output programs (Class & Objects) | set 1
- PHP find output programs (Class & Objects) | set 2
- PHP find output programs (Class & Objects) | set 3
- PHP find output programs (Constructors and Destructors) | set 1
- PHP find output programs (Constructors and Destructors) | set 2
- PHP find output programs (Constructors and Destructors) | set 3
- PHP find output programs (Inheritance) | set 1
- PHP find output programs (Inheritance) | set 2
- PHP find output programs (Inheritance) | set 3
Answer 1:
Output:
Explanation:
In the above program, we created a variable $string that contains a sentence, and we created a variable $search_pattern to search the specified pattern into the above string. The preg_match() function is used to check a specified substring is present in the string or not. The preg_match() function will return 0 because the specified pattern is not matched in the string.
Answer 2:
Output:
Explanation:
In the above program, we created a variable $string that contains a sentence, and we created a variable $search_pattern to search the specified pattern into the above string. The preg_match() function is used to check a specified substring is present in the string or not. Here, we used 'i' in the search pattern to ignore case for searching a sub-string. The preg_match() function will return 1 because the specified pattern is matched in a string.
Answer 3:
Output:
Explanation:
In the above program, we created a variable $string that contains a sentence, and we created a variable $search_pattern to search the specified pattern into the above string. The preg_match_all() function is used to return the count, how many times the specified pattern matched in the string.
In the above example, INCLUDE matched 2 times by ignoring the case. That's why preg_match_all() will return 2, that will be printed on the webpage.
Answer 4:
Output:
Explanation:
The above program will generate a warning, because we did not use correct syntax for preg_replace() function. The correct syntax of preg_replace() is given below:
preg_replace($pattern,"duggu",$string);
The preg_replace() is used to replace a specified pattern by specified substring in the string. Here, "include" will be replaced by "duggu" in the string $string.
Answer 5:
Output:
Explanation:
In the above program, we created a variable $string that contains a sentence, and we created a variable $pattern to replace the specified pattern by another substring into the above string.
The preg_replace() is used to replace a specified pattern by specified substring in the string, and return the modified string. But it will not change replace in the original string $string. That's why it will print "Includehelp is a web platform for learning, please www.includehelp.com" on the webpage.
need an explanation for this answer? contact us directly to get an explanation for this answer