Re: php-db Digest 28 Nov 2004 16:17:01 -0000 Issue 2703

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> ---------- Forwarded message ----------
> From: "balwantsingh" <balwantsingh@xxxxxxxxxxxxx>
> To: <php-db@xxxxxxxxxxxxx>
> Date: Sat, 27 Nov 2004 18:07:27 +0530
> Subject:  number format
> hello,
> 
> may pls. suggest me how i can retreive number before decimal and after
> decimal.
> for example 123456.7. I want to store 123456 in a variable and 7 in another.
> 
> also how can i force the user by validations so that he can only enter data
> in this format only i.e. 123456.7.
> 
> thanks
> 
> with best wishes
> balwant
> 

// Retrieve Number and Decimal Part
$num = "123456.7";
$num_part = substr($num, 0, strrpos($num, "."));
$dec_part = substr($num, strrpos($num, ".") + 1) ;

// Validation
if (preg_match("/^\d+\.\d+$/", $num)) {
   print("matched");
} else {
   print("not matched");
}


Regards,
Henry

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux