bleustreak12 Posted March 14, 2012 Share Posted March 14, 2012 I have written this in my asp.net application and have to now convert it to php string money_amount = ""; money_amount = Obj_12.Amount.ToString("N2"); Quote Link to comment https://forums.phpfreaks.com/topic/258909-tostringn2-in-php/ Share on other sites More sharing options...
Muddy_Funster Posted March 14, 2012 Share Posted March 14, 2012 sux to be you Quote Link to comment https://forums.phpfreaks.com/topic/258909-tostringn2-in-php/#findComment-1327321 Share on other sites More sharing options...
scootstah Posted March 14, 2012 Share Posted March 14, 2012 Okay. And? Quote Link to comment https://forums.phpfreaks.com/topic/258909-tostringn2-in-php/#findComment-1327323 Share on other sites More sharing options...
bleustreak12 Posted March 14, 2012 Author Share Posted March 14, 2012 What will be its PHP counterpart? Quote Link to comment https://forums.phpfreaks.com/topic/258909-tostringn2-in-php/#findComment-1327336 Share on other sites More sharing options...
scootstah Posted March 14, 2012 Share Posted March 14, 2012 PHP is loosely typed, so you do not have to cast one type to another to assign a variable. Quote Link to comment https://forums.phpfreaks.com/topic/258909-tostringn2-in-php/#findComment-1327339 Share on other sites More sharing options...
bleustreak12 Posted March 14, 2012 Author Share Posted March 14, 2012 Obj_12.Amount.ToString("N2"); will convert 987.1 to 987.10 I need the proper decimals Quote Link to comment https://forums.phpfreaks.com/topic/258909-tostringn2-in-php/#findComment-1327340 Share on other sites More sharing options...
DavidAM Posted March 14, 2012 Share Posted March 14, 2012 see number_format and/or money_format Quote Link to comment https://forums.phpfreaks.com/topic/258909-tostringn2-in-php/#findComment-1327341 Share on other sites More sharing options...
bleustreak12 Posted March 17, 2012 Author Share Posted March 17, 2012 I have the following code in asp.net Convert.ToDouble(Price) and I am confused should I use $value= number_format($Price, 2, '.', ''); or echo round($Price, 2); CAn anybody help me as to what it will be am I not using some PHP function Quote Link to comment https://forums.phpfreaks.com/topic/258909-tostringn2-in-php/#findComment-1328387 Share on other sites More sharing options...
salathe Posted March 17, 2012 Share Posted March 17, 2012 PHP is a loosely typed language, there is generally no real need to explicitly convert a value into a double (float, in PHP). Quote Link to comment https://forums.phpfreaks.com/topic/258909-tostringn2-in-php/#findComment-1328404 Share on other sites More sharing options...
bleustreak12 Posted March 24, 2012 Author Share Posted March 24, 2012 Thanks There are certain places where I need it to be double So I believe it should be echo (float)$Price; Right? Quote Link to comment https://forums.phpfreaks.com/topic/258909-tostringn2-in-php/#findComment-1330714 Share on other sites More sharing options...
bleustreak12 Posted March 24, 2012 Author Share Posted March 24, 2012 I am using this number_format($variable,2,'.',','); Is this right? Quote Link to comment https://forums.phpfreaks.com/topic/258909-tostringn2-in-php/#findComment-1330716 Share on other sites More sharing options...
trq Posted March 24, 2012 Share Posted March 24, 2012 I am using this number_format($variable,2,'.',','); Is this right? Does it work? Quote Link to comment https://forums.phpfreaks.com/topic/258909-tostringn2-in-php/#findComment-1330726 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.