根据给定的formData数组创建查询字符串

时间:2018-10-05 02:23:58

标签: php

我有一个需要生成查询字符串的数组列表 搜索类别数组必须是搜索数组的关键字,例如product_name = sampleProductName如果重复一个产品类别的实例,则结果需要是product_name = sampleProductName,sampleProductName2,对于searchCategory数组,我只需要获取在这种情况下,我只需要在查询字符串中使用数组4:supply_product_name

  

样本结果   ?product_name = sampleProductName,sampleProductName2&supply_product_name = sample_supplier,sample_supplier2&model_name = sampleModelName?is_displayF = T?is_displayT = T?is_sellingF = F?4 = supply_product_name

{search_flag: "T", shop_no: "1", searchCategory: Array(5), search: Array(5), depth1: "25", …}
    dateType: "regist_date"
    depth1: "25"
    depth2: "32"
    depth3: "36"
    depth4: "39"
    end_work_date: "2018-10-05"
    is_displayF: "F"
    is_displayT: "T"
    is_sellingF: "F"
    is_sellingT: "T"
    search: Array(5)
    0: "sampleProductName1"
    1: "sampleSupplier"
    2: "sampleProductName2"
    3: "sampleModelName"
    4: "sampleSupplier2"
    length: 5
    __proto__: Array(0)
    searchCategory: Array(5)
    0: "product_name"
    1: "supply_product_name"
    2: "product_name"
    3: "model_name"
    4: "supply_product_name"
    length: 5
    __proto__: Array(0)
    search_flag: "T"
    shop_no: "1"
    start_work_date: "2018-09-05"
    status_all: "on"
__proto__: Object

通过重组数组以使我的searchCategories和我的搜索数组成为一个我只取得了一点进展:

for($i = 0; $i < sizeof($aData['searchCategory']); $i++) {
    $aTempArray[$aData['searchCategory'][$i]] = $aData['search'][$i];
    array_push($aSearchCategories, $aTempArray);
}

使用strpos()尝试过,因此类别不会重复,但是问题是当搜索类别的排列变得不同时,它将仅在字符串中附加最后一个位置

0 个答案:

没有答案