Re: [PHP-DB] checking a string for numbers

2003-06-26 Thread Marco Tabini
On Thu, 2003-06-26 at 08:09, CPT John W. Holmes wrote: > if(preg_match('/[0-9]/',$myVar)) Same thing, fewer characters: if (preg_match('/\d/', $myVar)) Marco -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DB] checking a string for numbers

2003-06-26 Thread CPT John W. Holmes
From: "Jamie Saunders" <[EMAIL PROTECTED]> > I'm trying to find a way of simply checking a string for numbers. > > e.g. > > if ($myVar contains a number) > { > //numbers present > } > else > { > //no numbers present > } if(preg_match('/[0-9]/',$myVar)) { //number present } else { //no numb

Re: [PHP-DB] checking a string for numbers

2003-06-26 Thread Ignatius Reilly
$extract = preg_replace( "/[^0-9]/", "", $str ) // will extract the figures from your string HTH Ignatius _ - Original Message - From: "Jamie Saunders" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, June 26, 2003 1:04 PM Subject: [PHP-DB] checking a s

RE: [PHP-DB] checking a string for numbers

2003-06-26 Thread Snijders, Mark
you should use preg_match if (preg_match("/\d/",$myVar)){ echo "yes it contains a digit"; } i believe this works... you should use preg_match and with \d it checks for a digit i'm not sure this works... let me know -Original Message- From: Jamie Saunders [mailto:[EMAIL PROT