简体   繁体   English

我有一个数组,但是现在如何作为csv值插入php mysql

[英]I have an array but how do i now insert as csv values php mysql

I have this from my print_r 我有这个来自我的print_r

Array
(
    [jform] => Array
        (
            [itinerary] => Array
                (
                    [0] => 1
                    [1] => 2
                )

        )

)

I have some code and then this bit 我有一些代码,然后这一点

    foreach($_POST as $value) {

    $extraDATA[] = $value; 

    }

    $extraDATA = implode(',',$extraDATA);


   $updatEntry="UPDATE #__tours SET itinerary='$extraDATA' WHERE id='$id'";
   $db->setQuery($updatEntry);
   $db->query();

I can not get that array to produce 1,2 so i can update the row. 我不能使该数组产生1,2,所以我可以更新行。

Cheers in advance Jonny 提前欢呼乔尼

Sounds like you wanna do something like: 听起来您想执行以下操作:

$extraDATA = implode(',', $_POST['jform']['itinerary']);

Basically you wanna implode() the child-array that has no more children. 基本上,您想要implode()没有更多孩子的孩子数组。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM