號分離功能我寫的獨立編號,並插入一個功能,每3個字符 想轉換123456789
到123,456,789
錯誤在PHP
我的功能工作正常,但是當我用這個得到瀏覽器 我的功能3錯誤是這樣的:
function sefr($num){
array($lnn);
$len=strlen($num);
$zc=intval($len/3);
for ($za=0;$za<$len;$za++){
$lnn[$za]=substr($num,$za,1);
}
for ($zb=0;$zb<$len;$zb++){
if ($zb==$len-(3*$zc)){
if ($zb!=0){
$lnnn=$lnnn.",$lnn[$zb]";
}
else {
$lnnn=$lnnn.$lnn[$zb];
}
$zc--;
}
else {
$lnnn=$lnnn.$lnn[$zb];
}
}
return ($lnnn);
}
和我得到這個錯誤:
Notice: Undefined variable: lnn in file.php on line 2
Notice: Undefined variable: lnnn in file.php on line 14
Notice: Undefined variable: lnnn in file.php on line 19
使用[' number_format'](http://php.net/manual/en/function.number-format.php) – jeremy 2013-04-06 18:42:59
這些都是* Notices *,這是由於未初始化已使用的變量而產生的。 – mario 2013-04-06 18:43:22
謝謝, 我使用這個:$ number = number_format($ number); 是真的嗎? – Saitak 2013-04-06 18:47:01