Strings and Characters therein

From: Date: Mon, 04 Dec 2000 17:30:02 +0000
Subject: Strings and Characters therein
Groups: php.general 
Request: Send a blank email to php-general+get-28603@lists.php.net to get a copy of this message
I have a question that is more theoretical than practical: let's say i have a string containing a phone number formatted (for example) as: $phone="(207) 555-1212"; from which i want to remove everything but the numerals. i tried this code: <? for($i=0; $i < strlen($phone) $i++) { if(is_int($var[$j])) { $varOut.="$var[$j]"; } } print($varOut); ?> but it prints nothing. I then tried replacing the if(is_int($var[$j])) line with: if(($var[$j] >= "0") && ($var[$j] <= "9")) and this worked perfectly. so i did some more investigation and found that the gettype function, when applied to $var[$j] will always return the type "string", so of course the is_int function wouldn't work. so when is a value contained in a string an integer rather than a character? and can i convert from character to integer? is all data recieved from HTML forms considered to be a text string? thanks in advance.

« previous php.general (#28603) next »