WordPress的update_post_meta错误序列化

时间:2019-02-20 14:58:11

标签: wordpress custom-fields

为此meta_value

$new_meta_value = array (
    [244] => array
        (
            'course' => 244,
            'teacher' => array
                (
                    [0] => 608
                    [1] => 238
                ),
            'classroom' => 279,
            'price' => '300',
            'duration' => '01:30',
            'break' => '00:00',
            ),
);

update_post_meta($post_id, $meta_key, $new_meta_value)之后的序列化结果:

a:1:{i:0;a:9:{s:9:"teacher";i:1;s:9:"classroom";i:279;s:7:"course";i:244;s:8:"duration";s:5:"01:30";s:14:"break";s:5:"00:00";s:10:"start_date";s:10:"2019-02-20";s:10:"start_time";s:5:"13:30";s:5:"price";d:300;s:10:"exec_order";i:3;}}

teacher仅获得一个值0,因为索引为[0]

var_dump结果:

  

array(size = 1)254 => array(size = 6)'course'=> int 254'teacher'=> array(size = 2)0 =>字符串'608'(length = 3)1 = >字符串'236'(长度= 3)'教室'=>字符串'279'(长度= 3)'价格'=>字符串'200'(长度= 3)'持续时间'=>字符串'02:00'( length = 5)'break'=>字符串'00:00'(length = 5)

0 个答案:

没有答案