Parse query string into an array

前端 未结 10 2556
暖寄归人
暖寄归人 2020-11-22 02:58

How can I turn a string below into an array?

pg_id=2&parent_id=2&document&video 

This is the

10条回答
  •  春和景丽
    2020-11-22 03:51

    You want the parse_str function, and you need to set the second parameter to have the data put in an array instead of into individual variables.

    $get_string = "pg_id=2&parent_id=2&document&video";
    
    parse_str($get_string, $get_array);
    
    print_r($get_array);
    

提交回复
热议问题