php - Get all stored ID's from the arrayGet the solution ↓↓↓
I have an array which stores all ID's of episodes depending on tv show and amount of seasons. Each series has a different number of seasons.
And I need an Idea how to get all ID's from
$seasons['episodes'] no matter how many seasons it has.
I want it to returns to me all the ID of the episodes from the array.**
Array (  => Array ( [name] => Season 1 [image_id] => 2119 [episodes] => Array (  => 2122  => 2123  => 2124  => 2125  => 2126 ) [year] => 2017 [description] => Atypical is a coming-of-age television series created by Robia Rashid for Netflix. It focuses on the life of 18-year-old Sam Gardner (Keir Gilchrist), who is on the autism spectrum. The first season was released on August 11, 2017, consisting of eight episodes. [position] => 0 )  => Array ( [name] => Season 2 [image_id] => 2120 [episodes] => Array (  => 2127  => 2128  => 2129  => 2130  => 2131 ) [year] => 2018 [description] => The ten-episode second season was released on September 7, 2018. In October 2018, the series was renewed for a third season of ten episodes. [position] => 0 ) )
You are looking for
<?php $results = array_column($seasons, 'episodes'); // this will return 2d array of arrays with 'episodes' $final_results = call_user_func_array('array_merge', $results); // this will make 1d array of 2d array print_r($final_results); ?>
People are also looking for solutions of the problem: composer detected issues in your platform: your composer dependencies require a php version ">= 7.3.0".
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.