这个PHP数据的格式是什么?

时间:2018-04-04 22:19:29

标签: php serialization

我正在尝试找出这些数据的格式,因此我可以更改它。这太可怕了。

a:20:{s:12:"tagline_text";s:0:"";s:8:"gAddress";s:40:"380 North Shore Drive, Pittsburgh, 15212";s:8:"latitude";s:9:"40.445917";s:9:"longitude";s:10:"-80.011324";s:5:"phone";s:0:"";s:5:"email";s:0:"";s:7:"website";s:44:"http://tequilacowboy.com/pittsburgh/wannabs/";s:7:"twitter";s:0:"";s:8:"facebook";s:0:"";s:8:"linkedin";s:0:"";s:11:"google_plus";s:0:"";s:7:"youtube";s:0:"";s:9:"instagram";s:0:"";s:5:"video";s:0:"";s:7:"gallery";N;s:12:"price_status";s:0:"";s:10:"list_price";s:0:"";s:13:"list_price_to";s:0:"";s:15:"claimed_section";s:0:"";s:4:"faqs";a:2:{s:3:"faq";a:1:{i:0;s:0:"";}s:6:"faqans";a:1:{i:0;s:0:"";}}}

1 个答案:

答案 0 :(得分:2)

看起来PHP serialize()的输出给了我。您可以通过编写PHP脚本,从其文件中读取数据或其他任何内容将其解码回数组,并在其上使用unserialize()。

我测试了这个猜测:

<?php
// read $string from a file or something
print json_encode(unserialize($string));

运行此PHP代码:

php myscript.php | jq .

输出:

{
  "tagline_text": "",
  "gAddress": "380 North Shore Drive, Pittsburgh, 15212",
  "latitude": "40.445917",
  "longitude": "-80.011324",
  "phone": "",
  "email": "",
  "website": "http://tequilacowboy.com/pittsburgh/wannabs/",
  "twitter": "",
  "facebook": "",
  "linkedin": "",
  "google_plus": "",
  "youtube": "",
  "instagram": "",
  "video": "",
  "gallery": null,
  "price_status": "",
  "list_price": "",
  "list_price_to": "",
  "claimed_section": "",
  "faqs": {
    "faq": [
      ""
    ],
    "faqans": [
      ""
    ]
  }
}