Q:

PHP Multidimensional array conversion

Below is my PHP array:
[Paymentoption] => Array
    (
        [Paymentoption] => Array
            (
                [0] => Array
                    (
                        [0] => Array
                            (
                                [paymentoption_id] => 1
                            )

                        [1] => Array
                            (
                                [paymentoption_id] => 2
                            )

                        [2] => Array
                            (
                                [paymentoption_id] => 3
                            )

                        [3] => Array
                            (
                                [paymentoption_id] => 4
                            )

                    )

            )

    )

How Can I convert it to like:
[Paymentoption] => Array
    (
        [Paymentoption] => Array
            (
                [0] => 1
                [1] => 2
                [2] => 3
                [3] => 4
            )

    )

Thanks in advance ! 

A:

You can use array_map with a closure (php 5.3+) to transform your array. 
$array["PaymentOption"]["PaymentOption"] = 
    array_map(function($dat){ 
                  return $dat["paymentoption_id"]; 
              }, $array["PaymentOption"]["PaymentOption"][0]); 

