I'm using update_post_meta to save value of an array in the database,
$array_of_something = [['daysOfWeek' => [1],
'startTime' => '09:00',
'endTime' => '10:00'], [
'daysOfWeek' => [2],
'startTime' => '09:00',
'endTime' => '10:00'], [
'daysOfWeek' => [3],
'startTime' => '09:00',
'endTime' => '10:00'], [
'daysOfWeek' => [4],
'startTime' => '09:00',
'endTime' => '10:00'], [
'daysOfWeek' => [1],
'startTime' => '11:00',
'endTime' => '12:00'], [
'daysOfWeek' => [3],
'startTime' => '11:00',
'endTime' => '12:00']];
update_post_meta($post_id, 'my_meta_of_the_post', $array_of_something);
based on the documentation of codex:
A passed array will be serialized into a string
but the data is save to database like:
Array Array Array Array Array Array
and when I get the data using
get_post_meta($post_id, 'my_meta_of_the_post', true);
I'll get:
Array Array Array Array Array Array
but I expect that the value get serialize and saved in db, funny thing is if I do exact operation with
$array_of_something = [[['a'=>['value_aa','value_ab'],'b'=>'value_of_b']],[['c'=>['value_ca','value_cb'],'d'=>'value_of_d']]];
the value get serialized and correctly save in the database.
if I serialize the $array_of_something before saving using update_post_meta the value get double serialized in the db i have to use unserialize twice when calling get_post_meta and when I get it back, first unserialized work fine but the second one there is a <p> ... </P> tag around the value, which the value is okay but because of
tag around it it doesn't unserialiezed and return false
