2017-04-09 74 views
-2

我有两页如何通过url从产品页面获取值如果我点击产品名称,它将重定向到规格页面并从中获取值producat页面数组。如何通过产品页面数组中的URL获取值

PHP

产品页面

$array1 = Array(["b"]=>"value['brand']", 
      ["ref"]=>"value2['reference'] 

<a href="product.php?post=reference&<?php echo urlencode(serialize($array1));?>"> 

<h3 id="custompage">Product Name</span></h3></a> 

规格页

<h3 id="custom"><?php echo $_GET['brand']; ?><span><br></span></h3> 
+0

是否这样? http://stackoverflow.com/questions/1763508/passing-arrays-as-url-parameter – blackandorangecat

+0

[传递数组作为URL参数]可能的重复(http://stackoverflow.com/questions/1763508/passing-arrays-as -url参数) – mickmackusa

回答

0

你找http_build_query().

<?php 

$array1 = Array(
    "b"=>"brand", 
    "ref"=>"reference"); 

echo http_build_query($array1); 
//b=brand&ref=reference 

echo http_build_query($array1, '', '&amp;'); 
//b=brand&ref=reference 

?> 
相关问题