zkontrolujte, zda řetězec je číslo nebo ne php
$var_num = "1";
$var_str = "Hello World";
var_dump( is_numeric($var_num), is_numeric($var_str) );
/*
Output -
bool(true)
bool(false)
*/
php filtr pouze čísla
$output = preg_replace( '/[^0-9]/', '', $string );
php zkontrolujte, zda řetězec nebo číslo
<?php if (is_numeric(887)) { echo "Yes"; } else { echo "No"; } ?>
kontrola hodnoty obsahuje čísla nebo písmena php
ctype_digit(string text);
Parameter Used:
The ctype_digit() function in PHP accepts only one parameter.
text : Its mandatory parameter which specifies the tested string.
Return Values:
It returns TRUE if all characters of the string are numeric otherwise
return FALSE.
Input : '789495001'
Output : TRUE
Explanation : All digits, return True
Input : 'adc123' or '789.0877'
Output : FALSE
Explanation: String contains number and string or floating point,
return false.
zkontrolujte, zda obsahuje čísla php
if (preg_match('~[0-9]+~', $string)) {
echo 'string with numbers';
}