2017-04-09 72 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 

?> 
相關問題