• Resolved kingmaico

    (@kingmaico)


    Array ( [0] => stdClass Object ( [meta_value] => a:3:{i:0;s:30:”Aannemers, bouw en constructie”;i:1;s:34:”Administratie- en boekhoudkantoren”;i:2;s:20:”Agrarische bedrijven”;} ) )

    How do I get the values out of this array? Something like this:

    Aannemers, bouw en constructie

    Administratie- en boekhoudkantoren

    Agrarische bedrijven

Viewing 2 replies - 1 through 2 (of 2 total)
  • What you’re seeing there is an array that’s been serialised and saved as a meta value.

    For gettign values out of that, a guess would be…

    // Get the main meta object
    $meta_object = $array [0];
    
    // Get the serialised array from the object
    $meta_value = $meta_object->meta_value;
    
    // Un-serialise the array
    $meta_values = unserlialize ($meta_value);
    
    // Get the values
    echo $meta_values [0];
    echo $meta_values [1];
    echo $meta_values [2];
    Thread Starter kingmaico

    (@kingmaico)

    Goodmorning catacaustic! This is the solution. Thank you very much.
    There’s a tiny typo: in line 6 there’s an extra l (unserlialize)

    Just in case somebody else needs this as well.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get values from array’ is closed to new replies.