Struggling a bit here.
I’m trying to add an array using add_option.
When I try to access the array using get_option I’m not getting the results I expect.
Here’s a simple demo of my code:
$test = array( 'a' => 'b', 'c' => 'd', 'e' => 'f', ); add_option('something', "$test"); // I've done the register_setting bit earlier on $result = get_option("$test"); print_r ($result); // The output is Array echo '<br />'; echo $result ['e']; // The output is f
I’m not quite sure why print_r ($result) is only returning ‘Array’.
I want to access $result using foreach but obviously I’m not being allowed to since apparently there’s an empty array. 🙂
- The topic ‘Trying to use add_option to add an array, and get_option to access it’ is closed to new replies.