Re: Str to Int

From: Date: Fri, 20 Jan 2006 23:04:51 +0000
Subject: Re: Str to Int
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-228990@lists.php.net to get a copy of this message
You should be able to typecast the variable like so: $cardID = (int)$cardID; You can also check which type it is showing up as with the function gettype(): http://www.php.net/manual/en/function.gettype.php Optionally you could use settype() to change the type of the variable: http://www.php.net/manual/en/function.settype.php HTH -- Ray Hauge Programmer/Systems Administrator American Student Loan Services http://www.americanstudentloan.com 1.800.575.1099 On Friday 20 January 2006 03:53 pm, Ron Eggler (Paykiosks) wrote: > Hi, > > I need to do a type cast from string to int in folllowing code: > [php] > <getPIN cardID="'.intval(trim($cardID)).'" quantity="1" /> > [/php] > I need $cardID have converted to int. I thought it should work that way > but it does not! > But it's working if I'm putting > [php] > <getPIN cardID="180" quantity="1" /> > [/php] > in there. I got card ID as a var that is passed as get like: > [php] > $cardID = $HTTP_GET_VARS[cardID]; > [/php] > > Can anyone help me in that issue? Thank you! > > __________________________________________ > > Ron Eggler > Intern > 866-999-4179 > www.paykiosks.net

« previous php.general (#228990) next »