/**
* 方法1 php內建函數
*/
// $str = '1234567890';
// $newsnewstr = number_format($str. 🎜> // echo '
';
// echo $newstr;
/**
* 方法2 php自帶的函數實作
*/
🎜> $count = 3; //每幾個數分割一次
echo $str;
echo '
';
echo test($str test($str='',$count=3){
if(empty($str) || $count $str1 = strrev ($str); //反轉字串
$arr = str_split($str1,$count); //將字串分割成陣列
$new_str = join(',$arr); //連接字符串
return strrev($new_str); //再次反轉字符串並返回
}
?>
用到的內置函數
number_format()
> >$number
= 1234.56;;//noooo>;$english_format_number = number_format(
$nombre_format_francais
>$number, 2,
','
, ');// 1 234,56$number = $number = $number = ;// english notation without thousands separator
$english_format_number
$english_format_number$eng
(
$number,
2string
'.'
🎜>'');// 1234.57?>
?>
?>strrev()傳回 反轉後的字串。
echo strrev
(strrev(
"("); // 輸出 "!dlrow olleH"?>?>
?>?>?>?>
?>?>
?>將一維數組的值連接到一個
' >, 'email'
, 'phone');=
implode(","
, $array 🎜>echo
$comma_separated;
////Lmpty string> var_dump
(implode(
'hello'
, array>
'hello', array()); // string(0) ""?>str_split() 以上就介紹了 將一個字串(1234567890)轉換成(1,234,567,890)每三個一組用逗號隔開,包括了方面的內容,希望對PHP教程有興趣的朋友有所幫助。