如何显示我的数据库中的数据,但其中有空间?我的数据库中有数据“6285398980808”,但我想将其显示为“62 853 9898 0808”。 非常感谢任何建议。
最佳答案
如果您的号码固定为 13 位数字,您可以使用 preg_replace()
作为:
<?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
?>
关于php - 在php中用空格显示数据库中的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35146325/