开发者

Array to Serialize

i have an array like this

[Cuisine] => Array
        (
            [0] => Array
                (
                    [id] => 3
                    [name] => Arabian 
                    [slug] => 
                    [CuisinesRestaurant] => Array
                        (
                            [id] => 194
                            [restaurant_id] => 1
                            [cuisine_id] => 3
                        )

                )

            [1] => Array
                (
                    [id] => 5
                    [name] => Bengali 
                    [slug] => 
                    [CuisinesRestaurant] => Array
                        (
                            [id] 开发者_开发技巧=> 195
                            [restaurant_id] => 1
                            [cuisine_id] => 5
                        )

                )

            [2] => Array
                (
                    [id] => 7
                    [name] => Chettinad 
                    [slug] => 
                    [CuisinesRestaurant] => Array
                        (
                            [id] => 196
                            [restaurant_id] => 1
                            [cuisine_id] => 7
                        )

                )

        )

i wanna create a row with the name of each inner array like this

Arabian, Bengali, Chettinad

which is the best way to add a comma in between the cuisine names ?


Not sure i understand your question correct but something like this?

$allNames = array();

foreach ($data as $item)
{
    $allNames[] = $item['name'];
}

$data['all_names'] = implode(',', $allNames);

Where $data is your array.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜