Coder Social home page Coder Social logo

Comments (2)

ashokbasnet avatar ashokbasnet commented on June 28, 2024

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. 1,00,045.25
  2. 1,045.25
  3. 45

from cakephp-currency-helper.

ajain08 avatar ajain08 commented on June 28, 2024

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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.