Using String Matching vs. Pattern Matching : strrpos « String « PHP






Using String Matching vs. Pattern Matching

 
<?php 

$value = "my username"; 
if (strcmp($value, "user") == 0) { 
    echo "Found match in '" . $value . "' using strcmp.\n"; 
} else { 
    echo "Didn't find match in '" . $value . "' using strcmp.\n"; 
} 
if (!(strrpos($value,"user") ==="false)) {
    echo "Found match in '" . $value . "' using strrpos.\n"; 
} else { 
    echo "Didn't find match in '" . $value . "' using strrpos.\n"; 
} 
if (ereg("\<user\>", $value)) { 
    echo "Found match in '" . $value . "' using ereg.\n"; 
} else { 
    echo "Didn't find match in '" . $value . "' using ereg.\n"; 
} 
?>
  
  








Related examples in the same category

1.strrpos() function locates the last occurrence of character in string.
2.strrpos.php
3.Using several functions together to extract a portion of a string
4.A third parameter to strpos( ) that allows us to specify where to start searching from
5.Finding a substring with strpos()
6.Finding the Position of a Substring with strpos()
7.int strpos ( string haystack, mixed needle [, int offset] ) returns the index of the beginning of a substring's first occurrence within a string
8.strpos
9.strpos( ) will return false (as opposed to -1)
10.strpos() function finds the position of the first occurrence in string.
11.Return String found at position 22