how to pass an array in GET in PHP?

后端 未结 12 984
萌比男神i
萌比男神i 2020-11-28 14:37
$idArray = array(1,2,3,4);

can I write this line in HTML?

12条回答
  •  南笙
    南笙 (楼主)
    2020-11-28 15:02

    You could use serialize and & serialize along side with urlencode e.g.

    On Sending you can send them like these:

    "value1",["key2"]=>"value2");
    $array2 = Array(["key1"]=>"value1",["key2"]=>"value2");
    $data1="textdata";
    
    $urlPortion= '&array1='.urlencode(serialize($array1)).
                 '&array2='.urlencode(serialize($array2)).
                 '&data1='.urlencode(serialize($data1));
    //Full URL:
    $fullUrl='http://localhost/?somevariable=somevalue'.$urlPortion
    ?>
    

    On Receiving you can access them as:

    
    

    And Voila, you can attach that url on ajax request or normal browser page.

提交回复
热议问题