将json格式从2个数组更改为1个数组

时间:2016-07-14 07:21:36

标签: php mysql

我想从下面改变json格式。

Array
(
    [0] => Array
        (
            [notification_title] => Payment has processed completely! Kindly check you account.
            [notification_message] => Thank you for being our trusted driver and manage the ads on your car carefully. Your payment has proceded succesfully. Kindly check your account or credit.
        )

    [1] => Array
        (
            [notification_title] => Payment has processed completely! Kindly check you account.
            [notification_message] => Terimakasih atas kepercayaan dan kerjasama Anda bersama KarAds. Pembayaran Anda telah kami proses, silahkan lakukan pengecekan pada rekening bank atau kredit Anda pada compensation info. Kami tunggu partisipasi Anda untuk kampanye iklan lainnya. 
        )

)

进入下面的

Array
(
    [0] => Array
        (
            [notification_title] => Payment has processed completely! Kindly check you account.
            [notification_message] => Thank you for being our trusted driver and manage the ads on your car carefully. Your payment has proceded succesfully. Kindly check your account or credit.
            [notification_message_ind] => Terimakasih atas kepercayaan dan kerjasama Anda bersama KarAds. Pembayaran Anda telah kami proses, silahkan lakukan pengecekan pada rekening bank atau kredit Anda pada compensation info. Kami tunggu partisipasi Anda untuk kampanye iklan lainnya.    
)

我想要这样做的目的,我想将记录拆分为单独的列。

我目前的代码是爆炸它们。

$post_array = array(
                'notification_title' => $this->input->post('notification_title'),
                'notification_message' => $this->input->post('notification_message'),
                'notification_type' => $this->input->post('notification_type'),
                'notification_language' => $this->input->post('notification_language')
            );


        $data = array();
        $i = 0;
        foreach($post_array as $key=>$val) {
            $i = 0;
            foreach($val as $k=>$v) {
                $data[$i][$key] = $v;
                $i++;
            }
        }

        print_r($data);

0 个答案:

没有答案