【发布时间】:2015-05-12 05:24:01
【问题描述】:
我希望能够搜索标题为 Seattle 的数组,该数组将由一个变量设置。然后返回该数组的 x 或 y 坐标。我已经尝试了 5 或 6 种不同的方法来尝试定位它,但没有任何运气。
这是我正在使用的查询以及我如何打印我的数组:
global $wpdb;
$myquery = $wpdb->get_row("SELECT * FROM wp_maps WHERE title = 'Test Map'");
$mymap = $mylink->data;
print_r($mymap);
这是实际输出。
{ "title":"USA", "location":"World", "levels":[ { "id":"states", "title":"States", "locations":[{"id":"bhAAG","title":"Seattle","description":"The City of Goodwill","x":47.6097,"y":122.3331},{"id":"biAAG","title":"Portland","description":"Portland, Maine. Yes. Life’s good here.","x":43.6667,"y":70.2667}] } ] }
相同的输出(格式化以便于查看)。
{
"title":"USA",
"location":"World",
"levels":[
{
"id":"states",
"title":"States",
"locations":[
{
"id":"bhAAG",
"title":"Seattle",
"description":"The City of Goodwill",
"x":47.6097,
"y":122.3331
},
{
"id":"biAAG",
"title":"Portland",
"description":"Portland, Maine. Yes. Life’s good here.",
"x":43.6667,
"y":70.2667
}
]
}
]
}
任何帮助将不胜感激。
【问题讨论】:
-
使用 print_r($mymap) 的实际输出进行编辑
-
我已经添加了上面的实际输出。
标签: php arrays variables multidimensional-array