Converting a String to Int
| From: | Infomart) | Date: | Tue, 08 Apr 2003 18:21:08 +0000 |
| Subject: | Converting a String to Int | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-142936@lists.php.net to get a copy of this message | ||
Hi, I am sorry this question must seem too easy but I tried searching the
php.net site but couldn't find the answer.
I need to convert a string to an int. The reason is, I have to extract some
numbers from a text file. The text file is in the following format:
abtm 2002/06/11 2003/04/04 00:53 3,469 ABBOTSFORD TIMES
annw 1999/09/01 2003/04/02 20:15 7,481 ANCASTER NEWS
atad 2001/03/13 2002/09/10 19:55 2,227 THE ATHABASCA ADVOCATE
IDo you see the part that is bolded ? I need to take it out and subtract
that number with an existing integer that is stored in the database. The
problem is when I extract this number into a variable let's say $num =
3,469, for some reason $num is actually not an int, because I tried using
the is_int() function to check. ANd because of that when I try to subtract
this $num with another int variable, I get a number that is wrong because
$num isn't an integer, I am guessing it has to do with the comma (3,469) in
$num. Can I convert $num=3,469 into an int? If not, can I maybe take out
the comma and then convert it to int? Please help
THanks
Kelvin