php错误警告 - implode()[<a href="function.implode">function.implode</a>]:传递的参数无效

时间:2017-03-29 03:29:37

标签: php arrays

  

/var/www/html/development/cross/doli/www/app/service/class.order_management.php(2955):警告 - implode()[function.implode]:传递的参数无效

我的以下代码如下所示 -

$campaign_id = (empty($param_array['CampaignID']))?$split['campaign_sku']:$param_array['CampaignID'];
        $campaign_array = $this->get_campaign($job_type, $campaign_id, $split['skus'], $split['client_skus']);
        $job_type_array[] = $job_type;
        $this->client_obj_guid = $split['client_obj_guid'];
        $avail_param = array('client' => $this->client_obj_guid,
            'campaign' => $campaign_array[0],
            'digiSku' => $split['primary'],
            'skus' => implode(',', $split['secondary']),**The error is happening here, so I figure I would need to check $split to see if it is a array. Any help on this would be greatly appreciated.**
            'zip' => $customer_zip,
            'pos' => $pos_guid,
            'pos_sku' => $param_array['StoreID'],
            'inst' => $this->default_inst_obj_guid,
            'offer_count'=>(isset($param_array['NumberOfOfferings']))?$param_array['NumberOfOfferings']:'24',
            'job_type'=>$routing_job_type,
            'job_skus' => implode(',', $split['skus']),
            'total_capacity_units'=>$sku_array[$job_type]['capacity_units']);

1 个答案:

答案 0 :(得分:1)

函数implode期待一个数组,但传递给它的参数可能不是数组。因此,您必须检查$split['secondary']是否为数组。您可以按以下方式查看:

'skus' => is_array($split['secondary']) ? implode(',', $split['secondary']) : ''

如果''不是数组,此代码会将空字符串skus放入$split['secondary']