Saving multidimensional array in options not working

Question

I have the 3 following multidimensional arrays:

$mb_notice_section_1 = array(
    array( 'title'  => 'Title 1.00', 'message'  => 'Message 1.00' ),
    array( 'title'  => 'Title 1.01', 'message'  => 'Message 1.01' ),
    array( 'title'  => 'Title 1.02', 'message'  => 'Message 1.02' ),
    array( 'title'  => 'Title 1.03', 'message'  => 'Message 1.03' ),
    array( 'title'  => 'Title 1.04', 'message'  => 'Message 1.04' ),
    array( 'title'  => 'Title 1.05', 'message'  => 'Message 1.05' ),
    array( 'title'  => 'Title 1.06', 'message'  => 'Message 1.06' ),
    array( 'title'  => 'Title 1.07', 'message'  => 'Message 1.07' ),
    array( 'title'  => 'Title 1.08', 'message'  => 'Message 1.08' ),
    array( 'title'  => 'Title 1.09', 'message'  => 'Message 1.09' ),
    array( 'title'  => 'Title 1.10', 'message'  => 'Message 1.10' )
);

$mb_notice_section_2 = array(
    array( 'title'  => 'Title 2.00', 'message'  => 'Message 2.00' ),
    array( 'title'  => 'Title 2.01', 'message'  => 'Message 2.01' ),
    array( 'title'  => 'Title 2.02', 'message'  => 'Message 2.02' ),
    array( 'title'  => 'Title 2.03', 'message'  => 'Message 2.03' ),
    array( 'title'  => 'Title 2.04', 'message'  => 'Message 2.04' ),
    array( 'title'  => 'Title 2.05', 'message'  => 'Message 2.05' ),
    array( 'title'  => 'Title 2.06', 'message'  => 'Message 2.06' ),
    array( 'title'  => 'Title 2.07', 'message'  => 'Message 2.07' ),
    array( 'title'  => 'Title 2.08', 'message'  => 'Message 2.08' ),
    array( 'title'  => 'Title 2.09', 'message'  => 'Message 2.09' ),
    array( 'title'  => 'Title 2.10', 'message'  => 'Message 2.10' )
);

$mb_notice_section_3 = array(
    array( 'title'  => 'Title 3.00', 'message'  => 'Message 3.00' ),
    array( 'title'  => 'Title 3.01', 'message'  => 'Message 3.01' ),
    array( 'title'  => 'Title 3.02', 'message'  => 'Message 3.02' ),
    array( 'title'  => 'Title 3.03', 'message'  => 'Message 3.03' ),
    array( 'title'  => 'Title 3.04', 'message'  => 'Message 3.04' ),
    array( 'title'  => 'Title 3.05', 'message'  => 'Message 3.05' ),
    array( 'title'  => 'Title 3.06', 'message'  => 'Message 3.06' ),
    array( 'title'  => 'Title 3.07', 'message'  => 'Message 3.07' ),
    array( 'title'  => 'Title 3.08', 'message'  => 'Message 3.08' ),
    array( 'title'  => 'Title 3.09', 'message'  => 'Message 3.09' ),
    array( 'title'  => 'Title 3.10', 'message'  => 'Message 3.10' )
);

and when I try to save the generate dummy option it only seems to save the last one:

update_option( 'mb_notice_section_1', $mb_notice_section_1 );
update_option( 'mb_notice_section_2', $mb_notice_section_2 );
update_option( 'mb_notice_section_3', $mb_notice_section_3 );

Is there something that I am doing wrong, or can options not be named similarly?

For some reason all three of these arrays are getting the same option_id and are overriding each other – but being called as above.

0
, , , markb 2 years 2019-11-03T04:46:17-05:00 0 Answers 83 views 0

Leave an answer

Browse
Browse