php – 显示1k而不是1,000
发布时间:2020-12-13 18:25:31 所属栏目:PHP教程 来源:网络整理
导读:function restyle_text($input){ $input = number_format($input); $input_count = substr_count($input,','); if($input_count != '0'){ if($input_count == '1'){ return substr($input,+4).'k'; } else if($input_count == '2'){ return substr($input,+8
function restyle_text($input){ $input = number_format($input); $input_count = substr_count($input,','); if($input_count != '0'){ if($input_count == '1'){ return substr($input,+4).'k'; } else if($input_count == '2'){ return substr($input,+8).'mil'; } else if($input_count == '3'){ return substr($input,+12).'bil'; } else { return; } } else { return $input; } } 这是我的代码,我认为它正在运行.显然不是..有人可以提供帮助,因为我无法弄清楚这一点.
试试这个:
http://codepad.viper-7.com/jfa3uK function restyle_text($input){ $input = number_format($input); $input_count = substr_count($input,-4).'k'; } else if($input_count == '2'){ return substr($input,-8).'mil'; } else if($input_count == '3'){ return substr($input,-12).'bil'; } else { return; } } else { return $input; } } 基本上,我认为你使用substr()错了. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |