Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

http_build_query but replace & with ; in PHP?

Tags:

php

http_build_query($array) will convert array to the format of a=1&b=2,

But how to make it convert to the format of a=1;b=2?

Is there a native function there?

like image 835
kern Avatar asked May 12 '11 12:05

kern


People also ask

What does http_ build_ query do?

The http_build_query() function is an inbuilt function in PHP which is used to generate URL-encoded query string from the associative (or indexed) array.

What is query string in PHP example?

A query string is a term for adding/passing data in the URL. It is not language specific.

What is the use of query string in PHP?

Definition and Usage The parse_str() function parses a query string into variables. Note: If the array parameter is not set, variables set by this function will overwrite existing variables of the same name.


1 Answers

The third parameter to http_build_query is the separator; call it with http_build_query($array, "", ";") to get what you're after.

like image 171
Glen Solsberry Avatar answered Oct 13 '22 14:10

Glen Solsberry