2016-05-13 61 views
-4

試圖在成功頁面上購買購物車後獲取數據,但遇到$_GET問題。網址是:如何檢索URL中的數組?

http://domain.com/success.php?customer[email]=email%40gmail.com&order[button][description]=music+download&order[button][id]=89765464465423184847654556&order[button][name]=music&order[button][repeat]=&order[button][resource_path]=%2Fv2%2Fcheckouts%2F9db9d0ef-9cfd-52b9-b2d7-792683d2431d&order[button][subscription]=false

如何從這個分析數據在PHP?

+0

'echo $ _GET ['customer'] ['email'];'etc ... – AbraCadaver

回答

0

如果你的print_r $ _ GET變量,那麼它就會產生輸出:

Array 
(
    [customer] => Array 
     (
      [email] => [email protected] 
     ) 

    [order] => Array 
     (
      [button] => Array 
       (
        [description] => music download 
        [id] => 89765464465423184847654556 
        [name] => music 
        [repeat] => 
        [resource_path] => /v2/checkouts/9db9d0ef-9cfd-52b9-b2d7-792683d2431d 
        [subscription] => false 
       ) 

     ) 

) 

這意味着你可以通過$ _GET [ '客戶'] [ '電子郵件']和$ _GET ['爲了訪問您的數據'] ['button'] ['description'] etc ..

0

在您的示例中,您使用的是所謂的查詢字符串。爲了從檢索查詢字符串中的信息,$_GET超級全球存在,你可以按如下方式使用它:

$customer_email = $_GET['customer']['email']; 
$order_button_description = $_GET['order']['button']['description']; 
$order_button_id = $GET['order']['button']['id']; 
// etc. 

讓我知道是否有幫助。