2013-03-05 75 views
-2

我正在開發一個分析商店數據的網站。 我需要我的數組的URL部分看起來像這樣:URL的爆炸數組

array(
    'url'  => 'http://some.website.com:8080/SASStoredProcess/do?_username=user-123', 
    '_password' => 'passwd', 
    '_program' => '/Utilisateurs/DARTIES3-2012/Mon dossier/analyse_dc', 
    'annee'  => '2012', 
    'ind'  => 'V', 
    '_action' => 'execute' 
); 

我現在有這一點,並正在努力將其轉換爲所需的格式:

array(
    'url' => 'url=http://some.website.com:8080/SASStoredProcess/do?_username=user-123&_password=passwd&_program=%2FUtilisateurs%2FDARTIES3-2012%2FMon+dossier%2Fanalyse_dc&annee=2012&ind=V&_action=execute', 
    'otherKey' => 'otherValue' 
); 

請有人可以幫我轉換第二個代碼塊中的URL看起來像第一個代碼塊?提前致謝。

+1

看看http://php.net/manual/en/function.parse-str.php – Galen 2013-03-05 10:19:44

+2

你不應該在URL中傳遞密碼 – acutesoftware 2013-03-05 10:20:05

+0

你可以做一個foreach ... – 2013-03-05 10:20:08

回答

2

因此,這將提取您需要的表單的網址,爲$url

$myArray = array(
    'url' => 'url=http://some.website.com:8080/SASStoredProcess/do?_username=user-123&_password=passwd&_program=%2FUtilisateurs%2FDARTIES3-2012%2FMon+dossier%2Fanalyse_dc&annee=2012&ind=V&_action=execute', 
    'otherKey' => 'otherValue' 
); 
parse_str($myArray['url']); 
echo $url; 

您將需要決定它需要去下一步,你怎麼去那裏。