清单 2. 每个场所的 PHP 数据对象
stdClass Object
{
[id] => 5261
[name] => Driskill Hotel
[primarycategory] => stdClass Object
{
[id] => 79273
[fullpathname] => Travel:Hotel
[nodename] => Hotel
[iconurl] => http://foursquare.com/img/categories/travel/hotel.png
}
[address] => 604 Brazos St
[crossstreet] => at W 6th St
[city] => Austin
[state] => TX
[zip] => 78701
[geolat] => 30.2679601
[geolong] => -97.7413707
[stats] => stdClass Object
{
[herenow] => 0
}
[phone] => 5124745911
{
[id] => 5261
[name] => Driskill Hotel
[primarycategory] => stdClass Object
{
[id] => 79273
[fullpathname] => Travel:Hotel
[nodename] => Hotel
[iconurl] => http://foursquare.com/img/categories/travel/hotel.png
}
[address] => 604 Brazos St
[crossstreet] => at W 6th St
[city] => Austin
[state] => TX
[zip] => 78701
[geolat] => 30.2679601
[geolong] => -97.7413707
[stats] => stdClass Object
{
[herenow] => 0
}
[phone] => 5124745911
清单 3 中的代码片段提供整个 index.php 页面,通过一个数据结构循环完成,提取出一个 $final 数组的相关信息,然后使用这些信息来创建数据表。其结果是一个仪表板,显示场所名称、地址和电话号码,以及签入到那里的人数。
还要注意,由于电话号码并非场所的必要字段,因此您必须快速检查一下它是否包含在数据提要中。如果是,那么打印该号码,如果不是,则忽略它。