How to replace DOT by COMMA?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Moorad
    New Member
    • Jan 2011
    • 9

    How to replace DOT by COMMA?

    i have the following code

    Code:
    $debit = 0;
    					if ($TVA)
    					{
    						$debit = ($tab[$count_column][6 + $cpt_index]['value'] + ($tab[$count_column][5 + $cpt_index]['value'] ));
    						$debit = round($debit, 2);
    						if (strpos($debit, ".") == false)
    							$debit.= ".00";
    						$this->WriteReport($debit.";", $csv_name);
    					}
    					else
    					{
    						$this->WriteReport($credit.";", $csv_name);
    					}
    the result will be like 0.00

    i want it to be 0,00
    Last edited by Niheel; Jan 17 '11, 02:50 PM.
  • Sudaraka
    New Member
    • Jan 2011
    • 55

    #2
    Use number_format.
    Code:
    $credit=number_format($credit, 2, ',', '');

    Comment

    • kovik
      Recognized Expert Top Contributor
      • Jun 2007
      • 1044

      #3
      That code is very odd... It looks at your number as a string when your number is not a string at any point. You'll want to use number_format() to replace the round() and the strpos() use simultaneously.

      Comment

      • Moorad
        New Member
        • Jan 2011
        • 9

        #4
        i have use this code too but its not working :(

        Comment

        • Sudaraka
          New Member
          • Jan 2011
          • 55

          #5
          Could you explain what you mean by "not working"?

          Comment

          • Moorad
            New Member
            • Jan 2011
            • 9

            #6
            its ok, the code is good, i was wrongly placing it

            thank you very much for you help

            Comment

            • Sudaraka
              New Member
              • Jan 2011
              • 55

              #7
              You are welcome. Glad to help.

              Comment

              • Moorad
                New Member
                • Jan 2011
                • 9

                #8
                i have another question

                if i want to place the system date and cannot make modification, how should i do it ?

                Comment

                • Moorad
                  New Member
                  • Jan 2011
                  • 9

                  #9
                  i mean to say that the system date is entered automatically and the user cannot modify the date, how should i do it ?

                  Comment

                  • kovik
                    Recognized Expert Top Contributor
                    • Jun 2007
                    • 1044

                    #10
                    That is very vague. Place it where?

                    Comment

                    • Moorad
                      New Member
                      • Jan 2011
                      • 9

                      #11
                      i am creating a form, when i am filling the form there is a text box where i have to enter today's date

                      Comment

                      • kovik
                        Recognized Expert Top Contributor
                        • Jun 2007
                        • 1044

                        #12
                        And if you don't want this to be editable, then don't provide a text box for it. The forum post that you just made has a date and time on it, but you were never given the ability to select that. It was automatically generated and associated with your post after you pressed "submit."

                        Comment

                        Working...