• How do I go about using arrays for options? I believe that the following SHOULD work, but it didn’t when I tested it.

    $myarray = array(‘stuff’, ‘stuff’);
    update_option(‘mystuff’,$myarray);
    $newarray = get_option(‘mystuff’);
    $item = $newarray[1];

    With my plugin, that didn’t seem to work. Is there something I’m not doing right?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter nickgravelyn

    (@nickgravelyn)

    Oops. I didn’t mean $item=$newarray[1], I meant $item=$newarray[0], but that still doesn’t work. Any ideas?

    You may need to serialize and unserialize custom options — I’m not sure as I’ve always saved my own prefs. If there’s no quick answer, try the wp-hackers mailing list.

    I thought WP automagically serialized and unserialized when putting arrays in the database… Including update_option(), get_option(), and add_option()

    Thread Starter nickgravelyn

    (@nickgravelyn)

    It says it does automatically. I would like to do this because my plugin will be saving a lot of data to the options and it would be much easier to just have a couple of arrays of data to deal with than a lot of unique option names.

    Thread Starter nickgravelyn

    (@nickgravelyn)

    Has anyone else figured this out? I’ve been trying for days. It must be possible. Am I just doing it wrong?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Using Arrays As Options’ is closed to new replies.