How to show data from my database, but with space in it? I have data "6285398980808" on my database, but i want to show it like "62 853 9898 0808". Any suggestion greatly appreciated.
If your number fixed as 13 digits number than you can use preg_replace() as:
<?php
//62 853 9898 0808 required
$number = 6285398980808;
$formatted_number = preg_replace("/^(\d{2})(\d{3})(\d{4})(\d{4})$/", "$1 $2 $3 $4", $number);
echo $formatted_number; // 62 853 9898 0808
?>
There is a special function for that number_format - just play with parameters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With