Alex Alex - 1 year ago 106
PHP Question

PHP - create array from string

I have a string that looks like:


how could I create a array like this:

'single' => 'Single',
'multiple' => 'Multiple2',
'check' => 'check1',
'radio' => 'radio2',

Answer Source

Use parse_str

parse_str('single=Single&multiple=Multiple2&check=check1&radio=radio2', $data);

And in $data you will have your variables.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download