'Show all genres separated by "," (Array to string conversion)
This dump:
dd($moviesInformation['movies']['data'][1]['genres']);
show all genres for each movie returned like this:
^ array:2 [▼
"data" => array:32 [▼
0 => array:3 [▶]
1 => array:3 [▶]
2 => array:3 [▼
"id" => 446
"genre" => array:1 [▼
"label" => "Comedy"
]
"on_request" => 1
]
3 => array:3 [▶]
4 => array:3 [▶]
5 => array:3 [▶]
And I want to, based on this, have an output with all genres separated by ",", like this:
'result' => [Comedy, Action, etc],
However doing like this:
collect($moviesInformation['movies']['data'])->map(function ($movie) {
return [
'result' => implode(',', $movie['genres'])
];
});
Im getting "Array to string conversion". Do you know how to properly achieve that?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
