4. 文字列関数number_format()をフォーマットします
5. 文字列を配列function/emplode()に分割します。配列を文字列に連結する関数 implode()。<code><span>$str</span> = <span>"123445677"</span>; <span>$strl</span> = number_format(<span>$str</span>); <span>$str2</span> = number_format(<span>$str</span>,<span>2</span>); <span>$str3</span> = number_format(<span>$str</span>,<span>2</span>,<span>","</span>,<span>'.'</span>); <span>echo</span><span>$str</span>.<span>"<br/>"</span>; <span>echo</span><span>$strl</span>.<span>"<br/>"</span>; <span>echo</span><span>$str2</span>.<span>"<br/>"</span>; <span>echo</span><span>$str3</span>.<span>"<br/>"</span>;</code>
<code> 结果如下所示,number_format(str)表示在千分位上加,隔开。number_format(str,2)表示留两位小数点。number_format($str,2,",",".")把“,”替换成“.”。 </code>
<code><span>$str</span> = <span>"你好@php编程@每天进步一点"</span>; <span>$tem</span> = explode(<span>'@'</span>,<span>$str</span>); <span>$teml</span> = explode(<span>'@'</span>,<span>$str</span>,<span>2</span>); print_r(<span>$tem</span>); <span>echo</span><span>"<br/>"</span>; print_r(<span>$teml</span>);</code>
<code><span>$array</span> = <span>array</span>(<span>"hello"</span>,<span>"php编程"</span>,<span>"每天进步一点"</span>); <span>$str</span> = implode(<span>","</span>,<span>$array</span>); print_r(<span>$str</span>);</code>
<code> 结果如下图 。implode(separator,array)。 separator表示已什么来合成字符串。可选的。默认为空。array表示要合并成字符串的数组 </code>