String Operations PHP
15CSL77
WEB TECHNOLOGY LABORATORY WITH MINI PROJECT
program
Write a PHP program that declares a variable states with a value
"Mississippi Alabama Texas Massachusetts Kansas". write a PHP program that does
the following:
- Search for a word in variable states that end in xas. Store this word in element 0 of a list named statesList.
- Search for a word in states that begins with k and ends in s. Perform a case insensitive comparison. [Note: Passing re. Ias a second parameter to method compile performs a case-insensitive comparison.] Store this word in element1 of statesList.
- Search for a word in states that begins with M and ends in s. Store this word in element 2 of the list. d. Search for a word in states that ends in a. Store this word in element 3 of the list.
Basic Concepts
- The explode() function breaks a string into an array.
- preg_match – this function is used to perform a pattern match on a string.
code
output
search from string |
@cool
ReplyDelete