以下返回警告: range()预计至少有2个参数,给定1个。
无法弄明白。建议最欢迎。
**<?php
echo acct_type(110);
function acct_type($acct_no)
{ $sections = array(
'Current Asset' => '100,149',
'Fixed Asset' => '150,159',
'Accumulated Depreciation' => '160,169',
'Current Liability' => '200,249',
'Long Term Liability' => '250,299',
'Equity' => '300,399',
'Revenue' => '400,499',
'Cost of Goods Sold' => '500,599',
'Expense' => '600,699'
);
foreach($sections as $section => $range)
{ if(in_array($acct_no, range($range))) return $section;
}
}
?>**
答案 0 :(得分:2)
range()
需要两个参数http://php.net/manual/en/function.range.php
在你的程序中,你接受一个包含逗号的文本的字符串。
您需要拆分字符串并在range()
函数
foreach($sections as $section => $range)
{
list($min,$max)=explode(","$range);
if(in_array($acct_no, range($min,$max)))
return $section;
}