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"); 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 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? 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? 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. 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 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 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 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). 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? 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? 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? Link to comment https://forums.phpfreaks.com/topic/258909-tostringn2-in-php/#findComment-1330726 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.