how to convert number into sort form in php

How to Convert 1000 to 1k |using PHP

Welcome back to shorltearner.com, in our previous post we learn how to Convert words to numbers with the help of PHP. so in this post today we will learn how to convert number into sort number format in PHP.
so before start this tutorial we take an overview on number_format

Advertisement
which is also a predefined PHP function that are used to The number_format() function formats a number with grouped thousands.

how to convert number into sort form in php

Also Read :
PHP Login Script With Remember me.
Unable to create a directory a wordpress error
Change password using javascript, php and mysqli.
Password and Confirm Password Validation Using JavaScript
Check Email is Already Registered in Database using Ajax and JavaScript.
How to hide extension of html and php file.?

for example if i take the below code as an example

than the number_format function returns an output like

so If we want to convert number into sort form in thousand, million, billion then we used another predefined PHP function number_format_short that will help to convert any number to it’s sort form like (Eg: 1.4K, 14.32M, 40B ) etc.
so in the below code we take an example which converts a number 1,43,20000 into 14.32M.

Tags: No tags

Comments are closed.