Jayesh KR Jayesh KR - 1 year ago 70
PHP Question

How to convert an associative array into a simple array in php?

I have this:

array(2) { [0]=> string(3) "NBA" [1]=> string(7) "MGNREGS" }

I need it as

Can anyone help me with this.

Thanks in advance.

Answer Source

For which purpose do you need the array?

If you want to use JSON data, just try to call json_encode on the array:

$array = array('NBA', 'MGNREGS');
print json_encode($array);


array(2) { 
  [0]=> string(3) "NBA"
  [1]=> string(7) "MGNREGS"

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