PHP Question

PHP: Separate 2 or more values of 1 key in Array

I have array came from my ajax

$contestant_name_arr = $_GET['contestant_name_arr'];

Whenever i try to get the value of each in loop i got error because instead of this

Array ( [0] => value1,value2 )

It should be look like this:

Array (
[0] => value1
[1] => value2

How do I separate like that in the example above.

Answer Source

Either devise your url query string to be:[0]=value&contestant_name_arr[1]=value2

Or just simply explode;

$contestant_name_arr = explode(',', $contestant_name_arr[0]);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download