Issue
I'm trying to reverse a string and add spaces from 3 in 3 characters the code I have right now is this:
$rowPreco = "925000"
$rowPreco = strrev($rowPreco);
$rowPreco = wordwrap($rowPreco , 3 , ' ' , true );
$rowPreco = strrev($rowPreco);
if I take the strrev out it prints how I want ("925 000") but if I have the strrev it will print ("92 500 0").
But I need to use the strrev because if the value is ("1200000") it will print ("120 000 0") instead of ("1 200 000").
Any help would be appreciated.
Thanks!
UPDATE!
When I use the number_format it will ignore a jQuery code that I have.
echo "<script>"
."jQuery(document).ready(function() {"
."var parts = jQuery('.casaPreco').text().split('|');"
."jQuery('.casaPreco2').text(parts[4]);"
."});"
."</script>";
Basically the initial string is something like this: "3880562|1|1|925000|||0|0|0"
I need to grab the 4th number so I'm splitting the string on the "|" and use the array parts[4] but when I use the number_format it will grab the number "3880562"
Solution
Please do not invent the wheel:
echo number_format('925000', 0, '.', ' '); // 925 000
echo number_format('1200000', 0, '.', ' '); // 1 200 000
Answered By - u_mulder
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.