note 81405 deleted from function.is-numeric by nlopess
| From: | nlopess@php.net | Date: | Thu, 28 Feb 2008 20:24:13 +0000 |
| Subject: | note 81405 deleted from function.is-numeric by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-136573@lists.php.net to get a copy of this message | ||
Note Submitter: timdav83 at gmail dot com
----
Test if the first character is numeric or not:
function first_char_numeric($str){
$count = strlen($str);
$test = substr($str, -$count, 1);
if (is_numeric($test)) {
return true;
} else {
return false;
}
}
$str = "abcde"; // returns false
// $str = "2abcde"; // returns true
if(first_char_numeric($str) == "true")
{
echo "First character is numeric";
}else{
echo "First character is not numeric";
}