-2

I'm developing a site for analyzing a store's data. I need the url part of my array to look like this:

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'
);

I currently have this and am struggling to convert it to the desired format:

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'
);

Please can somebody help me to convert the URL in the second code block to look like the first code block? Thanks in advance.

CSᵠ
  • 10,049
  • 9
  • 41
  • 64
xonorageous
  • 2,281
  • 7
  • 26
  • 35

2 Answers2

2

You might want to use: parse_url() and parse_str() over your $array['url']

CSᵠ
  • 10,049
  • 9
  • 41
  • 64
2

So this will extract the url in the form you want, as $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;

You will need to decide where it needs to go next and how you get it there.

Raad
  • 4,540
  • 2
  • 24
  • 41