$categories
foreach 循环之前的结果 -
array(2) { [0]=> string(1) "1" [1]=> string(1) "2"}
$categories
foreach 循环中的结果 -
string(1) "1"string(1) "1"string(1) "2"string(1) "2"
$sortOrder
foreach 循环之前的结果 -
array(4) { [0]=> string(2) "20" [1]=> string(2) "13" [2]=> string(0) "" [3]=> string(0) ""}
$sortOrder
foreach 循环中的结果 -
string(2) "20"string(2) "13"string(0) ""string(0) ""string(2) "20"string(2) "13"string(0) ""string(0) ""
为什么我在 foreach 中得到双倍值?
foreach($categories as $cat)
{
foreach($sortOrder as $sort)
{
if(strlen($sort)>0)
{
//$this->Ps_products_model->brand_by_category_insert($brand_name,$brand_id,$cat,$sort,$state);
}
}
}
$this->load->view('admin/ajax/test', $data);
预期输出:
Cat: 1, Sort: 20
Cat: 2, Sort: 13