• Resolved fannyjukl

    (@fannyjukl)


    Hi, I like that plugin, but in some cases it throws only “Array” instead of directors etc. I have tried to delete cache, db, folder, turn cache off, turn it on, nothing happend. When I looked in db the directors collum says “a:2:{i:0;s:13:”Pierre Coffin”;i:1;s:12:”Chris Renaud”;}”. Is it the problem, or am I doing something wrong? Thanks

    EDIT: Sorry, I’m just stupid with wrong loop…

    https://wordpress.org/plugins/imdb-connector/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author thaikolja

    (@thaikolja)

    The way IMDb Connector works is thisL: It sends an URL to omdapi.com with the tite or ID of the movie you like t have information about. Then it deoends on your plugin settigs: If you’ve hosen to save the results in the database, arrays are being converted into JSON format which looks like your example:

    "a:2:{i:0;s:13:"Pierre Coffin";i:1;s:12:"Chris Renaud";}". 
    
    Same goes for local caching. That's the only way to store arrays outside of PHP environment.
    
    "actors" is a popular example for an array. In the omdbapi.com response, the actors are seperated between commas as a string, that means you could run
    
    <blockquote><?php echo get_imdb_connector_movie_detail("Seven", "genre"); ?></blockquote>
    
    which would simplt return a sting:
    
    <code>Brad Pitt, Edward Norton, Samuel L. Jaksons</code>
    
    and mazbe some more actors. I found that quite unflexible so I transformed alll o these into an array. That means the result of the above example function would look like:
    
    array("Tom Cruise", "Samuel L. Jackson")
    
    This is a lot more flexible because this waz I can target specific actors *for example only the second). I can also use the sort() function to sort the actor by their name so on or use count() to count how manz actors are in this array. That's why I've decided to split them up into arrays.
    
    You can see more information here: <a href="http://www.koljanolte.com/wordpress/plugins/secondary-title/">http://www.koljanolte.com/wordpress/plugins/secondary-title/</a>
    
    Let's say you want to display the actors as a normal string seperated by commas, you can easily do this by using:

    $movies = get_imdb_connector_movie(“Seven”);
    foreach($movies as $movie) {
    echo “"” . $movie[“title”] . ” was produced in the yearof ” . $movie[“uear”] . “.”;
    }`

    But I’ve planned for the next version to include an option where ALL arras merge into a single string. Until then, you’d have to ue the method above.

    I hope I could help a bit,

    Kolja

    Thread Starter fannyjukl

    (@fannyjukl)

    You are awesome! 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Wrong string or array’ is closed to new replies.