How to check how many characters in variable, and add space between characters in that var?
I have a 'price' variable that contains some integer number from a MySQL database.
I want to check how many numbers the 'price' variable contains, and add a space in the variable depending on how many numbers. See below:
If 'price' is 150000 I would like the output to be 150 000 (notice the space). OR, if it is 19000 I would like it to output 19 000...
How would you do this the easiest way?
The easiest way is to use
$str = number_format($number, 0, '.', ' ');
- A Linux, Apache, MySQL, PHP (LAMP) stack is a combination of open source software that is typically installed together to enable a server to host dynamic […]
- MySQL is an the most popular open-source database management system, in most of hosting company its has been bundle by LAMP(Linux, Apache, MySQL, PHP/Python/Perl) stack. Another alternative […]
- MySQL is the world’s most popular open-source database. Despite its powerful features, MySQL is simple to set up and easy to use. Below are some instructions […]