[PHP] Converting variables to integer

2002-11-06 Thread drparker
I have a bunch of form variables that I need to process as integers. The problem is that some users are writing in values with commas - e.g. 100,000, and that isn't read as an integer. There's more than one variable so I don't want to have to do a string replace for each one. Is there a general

Re: [PHP] Converting variables to integer

2002-11-06 Thread Kevin Stone
; else return false; } Loop through your form variables and call this function. Good luck, -Kevin - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 9:05 AM Subject: [PHP] Converting variables to integer I have a bunch

Re: [PHP] Converting variables to integer

2002-11-06 Thread Marek Kilimajer
This should work for you, this recursive function loops the array, if it gets array again, calls itself function convert2int($var) { foreach($var as $k = $v ) { if(is_array($v)) { $var[$k]=convert2int($v); } else { $var[$k]=str_replace(',',$v); } }

Re: [PHP] Converting variables to integer

2002-11-06 Thread Kevin Stone
Ooops my str_replace() function needs one more parameter. str_replace(',', '', $str); -Kevin - Original Message - From: Kevin Stone [EMAIL PROTECTED] To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 11:45 AM Subject: Re: [PHP] Converting variables to integer