Every String may contain Float Value, Character Value, Integer Value, Double Value and etc. In this Example we are going to show only integer value that a string may contains. this example uses regular expression for checking a string that may contain integer values.
The Following Example is showing to find out integer value among some string.
The Following Example is showing to find out integer value among some string.
function string_contains_int($string) {
return preg_match("/^[1-9][0-9]*$/", $string);
}
Example Consists$string = "6546545987"; $string_contains_int = string_contains_int($string); echo ($string_contains_int == 1 ? "True" : "False");
After Execution Output is - Output: True
$string = "65465459gg87"; $string_contains_int = string_contains_int($string); echo ($string_contains_int == 1 ? "True" : "False");
After Execution Output is - Output: False
$string = "65467.50"; $string_contains_int = string_contains_int($string); echo ($string_contains_int == 1 ? "True" : "False");
After Execution Output is - Output: False
And if you face any problem then contact me from the contact from i will reply you as soon as possible.
Query about blogging and adsense also welcome.
Thanks
0 comments :
Post a Comment