Hello, Is there anyway I can convert character numbers (matched by a preg_match and stored into a string) into integer numbers so that I can compare them (==, >, <,...) with other integer variables?
$chars = $result_of_preg_match; //EX string = 45309238 $ints = (int)$chars; //OUTPUT = int 45309238 PHP:
Or: $chars = $result_of_preg_match; //EX string = 45309238 $ints = $chars+0; //OUTPUT = int 45309238 PHP:
In one line this should work (if you do not need the $chars) $ints = intval($result_of_preg_match); Code (markup): intval() can also convert from other 'base' for example Hexadecimal. have a look here http://nl.php.net/manual/en/function.intval.php for details