【发布时间】:2014-08-06 00:54:04
【问题描述】:
如何使用 PHP 正则表达式提取特定值并将其放入如下变量中:
$output = 'testing tag speaker on left';
这就是我要解析的变量的样子:
$test ='
\"sticky\": {
\"type\": \"area\",
\"positionLeft\": \"23.90625\",
\"positionTop\": \"19.6875\",
\"id\": \"false\",
\"allowToModify\": \"true\"
},
\"area\": {
\"width\": \"95.625\",
\"height\": \"170.625\",
\"caption\": \"testingtagspeakeronleft\"
},
\"spot\": {
\"bubbleDirection\": \"top\",
\"title\": \"\",
\"content\": \"\",
\"contentRaw\": \"\",
\"size\": \"0\",
\"color\": \"white\",
\"urlSpot\": \"\",
\"urlSpotTarget\": \"_self\",
\"urlGoogle\": \"\",
\"urlYouTube\": \"\",
\"urlVimeo\": \"\",
\"urlWikipedia\": \"\",
\"urlFacebook\": \"\"
}
';
【问题讨论】:
-
你试过json_decode吗?
-
你从哪里得到这些数据?
-
@thg435 我对此并不熟悉,但我需要使用 php 来完成
-
@hek2mgl 它来自 wp-stickies
-
这看起来像一个 JSON 字符串。您可以使用
json_decode对其进行解码。如果您不知道 JSON 是什么,请尝试查找。