Domanda

this is how i get the array below.

$moviess = VideoLibrary::getMovies(

        array("properties" => array()
        ));

array(275) { [0]=> object(stdClass)#68 (2) { ["label"]=> string(16) "2 Fast 2 Furious" ["movieid"]=> int(1) } 
             [1]=> object(stdClass)#351 (2) { ["label"]=> string(6) "2 Guns" ["movieid"]=> int(2) }
             [2]=> object(stdClass)#352 (2) { ["label"]=> string(12) "3:10 to Yuma" ["movieid"]=> int(12) }
             [3]=> object(stdClass)#353 (2) { ["label"]=> string(1) "9" ["movieid"]=> int(3) }
             [4]=> object(stdClass)#354 (2) { ["label"]=> string(9) "10,000 BC" ["movieid"]=> int(4) 

im trying to retrieve the movieid from that array

to add it to the code below

$indexdetails = VideoLibrary::getMovieDetails({**I NEED THE movieID HERE FROM THAT ARRAY**}, array(
            'title',
            'genre',
            'year',
            'rating',
            'tagline',
            'plot',
            'mpaa',
            'cast',
            'imdbnumber',
            'runtime',
            'streamdetails',
            'votes',
            'thumbnail',
            'trailer',
            'file',
            'playcount'

        ));


This kind of works:

$movies = VideoLibrary::getMovies($requestParameters);
foreach($movies as $mv)
{
    $indexdetails = VideoLibrary::getMovieDetails($mv->movieid, array(
        'title',
    ));

    var_dump($indexdetails);
}

But when I try to echo $mv->title; I get str error. When I try $mv['title'] I get something different:

PHP Fatal error: Cannot use object of type stdClass as array

È stato utile?

Soluzione

From the looks of it, you can probably do this:

$movieDetails = array();
foreach ($moviess as $movie) {
    $movieDetails[$movie->movieid] = VideoLibrary::getMovieDetails(
        $movie->movieid,
        array(
            // ...
        )
    );

    echo $movieDetails[$movie->movieid]->title;
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top