Add Array record to Meta Post

by Rob Guay   Last Updated February 27, 2019 05:08 AM

I am trying to add the following array into the meta post table

"a:2:{s:11:"target";a:1:{i:0;a:1:{i:1;a:3:{s:5:"param";s:13:"page_selected";s:8:"operator";s:2:"==";s:5:"value";a:5:{i:3001;s:13:"Service Areas";i:1098;s:19:"Water Slide Rentals";i:672;s:15:"Chairs & Tables";i:205;s:4:"Home";i:1401;s:29:"Bounce House Rental Armada MI";}}}}s:15:"sgpb-conditions";N;}"

I broke down the array as follows

a:2:{ ## ARRAY 1 [3 ELEMENTS]
-->KEY   VALUE 1-1
s:11:"target";   a:1:{ ## ARRAY 2 [2 ELEMENTS]

-->KEY   VALUE 1-2
i:0;   a:1:{ ## ARRAY 3 [2 ELEMENTS]

-->KEY   VALUE 2-1
i:1;   a:3:{ ## ARRAY 3 [4 ELEMENTS]

-->KEY   VALUE 3-1
s:5:"param";   s:13:"page_selected";

-->KEY   VALUE 3-2
s:8:"operator";   s:2:"==";

-->KEY   VALUE 3-3
s:5:"value";   a:5:{ ## ARRAY 4 [6 ELEMENTS]

-->KEY   VALUE 4-1
i:3001;   s:13:"Service Areas";

-->KEY   VALUE 4-2
i:1098;   s:19:"Water Slide Rentals";

-->KEY   VALUE 4-3
i:672;   s:15:"Chairs & Tables";

-->KEY   VALUE 4-4
i:205;   s:4:"Home";

-->KEY   VALUE 4-5
i:1401;   s:29:"Bounce House Rental Armada MI";

}
}
}
}
s:15:"sgpb-conditions";N;}
^^^^^^^^^^^^^^^^^^^^^^^^^^

NOT SURE HOW THIS TIES IN

my question is about First issue I am having is a complete understanding of the array. Not sure how the last values tie into an array. Also, an Array is zero based correct?

Here is the code I have created so far to add the array, which is not creating the array correctly.

" $poddata = Array(
'sgpb-target',
Array (
1 => Array(
'param' => 'page_selected',
'operator' => '==',
'value' => Array(
3001 => 'Service Areas',
1098 => 'Water Slide Rentals',
672 => 'Chairs & Tables',
1401 => 'Bounce House Rental Armada MI',
676 => 'Mobile Gaming Trucks'
))));

update_post_meta(6668, 'poddata', $poddata);
?>"

Thanks for any help



Related Questions


Updated June 18, 2015 23:03 PM

Updated March 12, 2016 07:03 AM

Updated June 27, 2017 14:08 PM

Updated June 03, 2019 04:08 AM

Updated July 24, 2016 08:03 AM