我得到一个未定义的偏移误差在PHP函数未定义偏移PHP的错误1
错误代码
PHP公告:未定义抵消:1个
PHP公告:未定义抵消:-1
function thousandsCurrencyFormat($num) {
$x = round($num);
$x_number_format = number_format($x);
$x_array = explode(',', $x_number_format);
$x_parts = array('k', 'm', 'b', 't');
$x_count_parts = count($x_array) - 1;
$x_display = $x;
$x_display = $x_array[0] . ((int) $x_array[1][0] !== 0 ? '.' . $x_array[1][0] : '');
$x_display .= $x_parts[$x_count_parts - 1];
return $x_display;
}
这些都是两条线,我有这个错误
$x_display = $x_array[0] . ((int) $x_array[1][0] !== 0 ? '.' . $x_array[1][0] : '');
$x_display .= $x_parts[$x_count_parts - 1];
我该如何解决这个问题?感谢您的帮助
因为如果传递'100'那么'$ x_array'只包含你得到的错误'1'次数即'x_array [0]'你需要验证输入的号码是最少'1000' – RiggsFolly
也许你可以使用简单的[number_format()](http://php.net/manual/en/function.number-format.php) – RiggsFolly
可能的重复[参考 - 这个错误意味着什么PHP?](http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php) –