how to send array values through url in PHP?

2020-02-09 20:38发布

how to send array through url in PHP?

I have an array of product ids i want to use these id through url because this is the osCommerce needs it in which i am working in, how can i do it?

Generally osCommerce asks for the single product insertion which in turn gives me back a product id which i pass into the url and get it in shopping cart where i am shown this added product, but now i have multiple products added in first page with different generated product ids and i have to display these products the same way they are displayed in genaral, for which i will need all these generated ids here in url

标签: php url
7条回答
淡お忘
2楼-- · 2020-02-09 20:58

Your looking for http_build_query().

Example from php.net:

$data = array('foo'=>'bar',
              'baz'=>'boom',
              'cow'=>'milk',
              'php'=>'hypertext processor');

echo http_build_query($data);
// foo=bar&baz=boom&cow=milk&php=hypertext+processor

echo http_build_query($data, '', '&');
// foo=bar&baz=boom&cow=milk&php=hypertext+processor
查看更多
登录 后发表回答