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