views:

15

answers:

1

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 ?

+1  A: 

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.

madsleejensen
thanks. thats what i wanted. guess didnt ask it more clearly :D
Harsha M V