在PHP中反序列化数据

时间:2018-07-09 04:48:47

标签: php

Item_id = 123200194926和transaction_id = 1970816179002

如何从下面获取item_id和transaction_id

a: 1: {
  s: 16: "m2epro_extension";
  a: 1: {
    s: 5: "items";
    a: 1: {
      i: 0;
      a: 2: {
        s: 7: "item_id";
        s: 12: "123200194926";
        s: 14: "transaction_id";
        s: 13: "1970816179002";
      }
    }
  }
}

1 个答案:

答案 0 :(得分:0)

我找到了解决方法:

print_r(unserialize($_item->getAdditionalData()));

结果:

Array
(
    [m2epro_extension] => Array
        (
            [items] => Array
                (
                    [0] => Array
                        (
                            [item_id] => 123200194926
                            [transaction_id] => 1970816179002
                        )

                )

        )

)