check if a string starts with an integer
Moderator: General Moderators
check if a string starts with an integer
Hi I wanna check if a string starts with an integer, I know I need to use a pregnatch in some way but for the life of me I cant seem to get it right, anyone help? thanks....
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Try something like:
Mac
Code: Select all
$string = '12something';
if (preg_match('/^[0-9]/', $string)) {
// string starts with number
} else {
// string doesn't start with a number
}