Comments (2)
It's working good in CAKE 2.3.5. Can you provide me the cake version you are working at?
Here is the output:
- 1,00,045.25
- 1,045.25
- 45
from cakephp-currency-helper.
Hi,
Thanks for reply. I am using CAKE 1.3.15. But I think their was a logical issue in the function "formatNprInr". I have resolved it. Kindly review the changes in function
// For formatting Nepali and Indian Rupees
function formatNprInr($input){
//CUSTOM FUNCTION TO GENERATE ##,##,###.##
$dec = "";
$pos = strpos($input, ".");
if ($pos === false){
//no decimals
} else {
//decimals
$dec = substr(round(substr($input,$pos),2),1);
$input = substr($input,0,$pos);
}
if(strlen($input) > 3){// Added Condition by Ashish
$num = substr($input,-3); //get the last 3 digits 500
$input = substr($input,0, -3); //omit the last 3 digits already stored in $num 4
while(strlen($input) > 0 ) //loop the process - further get digits 2 by 2
{
if(strlen($input) >=2) {// Added Condition by Ashish
$num = substr($input,-2).",".$num; //It return nothing if strlen($input) is 1
$input = substr($input,0,-2);
} else {
$num = substr($input,-1).",".$num;
$input = substr($input,0,-1);
}
}
return $num . $dec;
}else{
return $input . $dec;
}
}
I hope you will get it.
from cakephp-currency-helper.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cakephp-currency-helper.