当前位置: 首页>>代码示例>>PHP>>正文


PHP xml::spliceMultiData方法代码示例

本文整理汇总了PHP中xml::spliceMultiData方法的典型用法代码示例。如果您正苦于以下问题:PHP xml::spliceMultiData方法的具体用法?PHP xml::spliceMultiData怎么用?PHP xml::spliceMultiData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xml的用法示例。


在下文中一共展示了xml::spliceMultiData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: lookup

 public function lookup($rk_num)
 {
     $serverstat = xml::getUrl("http://probes.funcom.com/ao.xml", 30);
     if ($serverstat == null) {
         return null;
     }
     $data = xml::spliceData($serverstat, "<dimension name=\"d{$rk_num}", "</dimension>");
     if (!$data) {
         return null;
     }
     $obj = new ServerStatus();
     preg_match("/locked=\"(0|1)\"/i", $data, $tmp);
     $obj->locked = $tmp[1];
     preg_match("/<omni percent=\"([0-9.]+)\"\\/>/i", $data, $tmp);
     $obj->omni = $tmp[1];
     preg_match("/<neutral percent=\"([0-9.]+)\"\\/>/i", $data, $tmp);
     $obj->neutral = $tmp[1];
     preg_match("/<clan percent=\"([0-9.]+)\"\\/>/i", $data, $tmp);
     $obj->clan = $tmp[1];
     preg_match("/<servermanager status=\"([0-9]+)\"\\/>/i", $data, $tmp);
     $obj->servermanager = $tmp[1];
     preg_match("/<clientmanager status=\"([0-9]+)\"\\/>/i", $data, $tmp);
     $obj->clientmanager = $tmp[1];
     preg_match("/<chatserver status=\"([0-9]+)\"\\/>/i", $data, $tmp);
     $obj->chatserver = $tmp[1];
     preg_match("/display-name=\"(.+)\" loadmax/i", $data, $tmp);
     $obj->name = $tmp[1];
     $data = xml::spliceMultiData($data, "<playfield", "/>");
     foreach ($data as $hdata) {
         if (preg_match("/id=\"(.+)\" name=\"(.+)\" status=\"(.+)\" load=\"(.+)\" players=\"(.+)%\"/i", $hdata, $arr)) {
             $playfield = new stdClass();
             $playfield->id = $arr[1];
             $playfield->long_name = $arr[2];
             $playfield->status = $arr[3];
             $playfield->load = $arr[4];
             $playfield->percent = $arr[5];
             $obj->data[$arr[1]] = $playfield;
         }
     }
     return $obj;
 }
开发者ID:jibinam,项目名称:budabot2,代码行数:41,代码来源:ServerStatusController.class.php

示例2: weatherCommand

 /**
  * @HandlesCommand("weather")
  * @Matches("/^weather (.+)$/i")
  */
 public function weatherCommand($message, $channel, $sender, $sendto, $args)
 {
     $location = $args[1];
     $blob = '';
     $host = "api.wunderground.com";
     $geolookup = "/auto/wui/geo/GeoLookupXML/index.xml?query=" . urlencode($location);
     $current = "/auto/wui/geo/WXCurrentObXML/index.xml?query=" . urlencode($location);
     $forecast = "/auto/wui/geo/ForecastXML/index.xml?query=" . urlencode($location);
     $alerts = "/auto/wui/geo/AlertsXML/index.xml?query=" . urlencode($location);
     $geolookup = $this->getweatherdata("api.wunderground.com", 80, $geolookup);
     // Geolookup
     if (xml::spliceData($geolookup, "<wui_error>", "</wui_error>") != "") {
         $sendto->reply("No information is available for <highlight>" . $location . "<end>.");
         return;
     }
     $locations = xml::spliceMultiData($geolookup, "<name>", "</name>");
     if (count($locations) > 1) {
         $blob .= "Multiple hits for {$location}.\n\n";
         foreach ($locations as $spot) {
             $blob .= $this->text->make_chatcmd($spot, "/tell <myname> weather {$spot}") . "\n";
         }
         $msg = $this->text->make_blob('Weather Locations', $blob);
         $sendto->reply($msg);
         return;
     }
     $sendto->reply("Collecting data for <highlight>" . $location . "<end>.");
     $current = $this->getweatherdata("api.wunderground.com", 80, $current);
     $forecast = $this->getweatherdata("api.wunderground.com", 80, $forecast);
     $alerts = $this->getweatherdata("api.wunderground.com", 80, $alerts);
     // CURRENT
     $updated = xml::spliceData($current, "<observation_time_rfc822>", "</observation_time_rfc822>");
     if ($updated == ", :: GMT") {
         $sendto->reply("No information is available for <highlight>" . $location . "<end>.");
         return;
     }
     $credit = xml::spliceData($current, "<credit>", "</credit>");
     $crediturl = xml::spliceData($current, "<credit_URL>", "</credit_URL>");
     $observeLoc = xml::spliceData($current, "<observation_location>", "</observation_location>");
     $fullLoc = xml::spliceData($observeLoc, "<full>", "</full>");
     $country = xml::spliceData($observeLoc, "<country>", "</country>");
     $lat = xml::spliceData($observeLoc, "<latitude>", "</latitude>");
     $lon = xml::spliceData($observeLoc, "<longitude>", "</longitude>");
     $elevation = xml::spliceData($observeLoc, "<elevation>", "</elevation>");
     $weather = xml::spliceData($current, "<weather>", "</weather>");
     $tempstr = xml::spliceData($current, "<temperature_string>", "</temperature_string>");
     $humidity = xml::spliceData($current, "<relative_humidity>", "</relative_humidity>");
     $windstr = xml::spliceData($current, "<wind_string>", "</wind_string>");
     $windgust = xml::spliceData($current, "<wind_gust_mph>", "</wind_gust_mph>");
     $pressurestr = xml::spliceData($current, "<pressure_string>", "</pressure_string>");
     $dewstr = xml::spliceData($current, "<dewpoint_string>", "</dewpoint_string>");
     $heatstr = xml::spliceData($current, "<heat_index_string>", "</heat_index_string>");
     $windchillstr = xml::spliceData($current, "<windchill_string>", "</windchill_string>");
     $visibilitymi = xml::spliceData($current, "<visibility_mi>", "</visibility_mi>");
     $visibilitykm = xml::spliceData($current, "<visibility_km>", "</visibility_km>");
     $latlonstr = number_format(abs($lat), 1);
     if (abs($lat) == $lat) {
         $latlonstr .= "N ";
     } else {
         $latlonstr .= "S ";
     }
     $latlonstr .= number_format(abs($lon), 1);
     if (abs($lon) == $lon) {
         $latlonstr .= "E ";
     } else {
         $latlonstr .= "W ";
     }
     $latlonstr .= $this->text->make_chatcmd("Google Map", "/start http://maps.google.com/maps?q={$lat},{$lon}") . " ";
     $latlonstr .= $this->text->make_chatcmd("Wunder Map", "/start http://www.wunderground.com/wundermap/?lat={$lat}&lon={$lon}&zoom=10") . "\n\n";
     $blob .= "Credit: <highlight>" . $this->text->make_chatcmd($credit, "/start {$crediturl}") . "<end>\n";
     $blob .= "Last Updated: <highlight>{$updated}<end>\n\n";
     $blob .= "Location: <highlight>{$fullLoc}, {$country}<end>\n";
     $blob .= "Lat/Lon: <highlight>{$latlonstr}<end>";
     $blob .= "Currently: <highlight>{$tempstr}, {$weather}<end>\n";
     $blob .= "Humidity: <highlight>{$humidity}<end>\n";
     $blob .= "Dew Point: <highlight>{$dewstr}<end>\n";
     $blob .= "Wind: <highlight>{$windstr}<end>";
     if ($windgust) {
         $blob .= " (Gust:{$windgust} mph)\n";
     } else {
         $blob .= "\n";
     }
     if ($heatstr != "NA") {
         $blob .= "Heat Index: <highlight>{$heatstr}<end>\n";
     }
     if ($windchillstr != "NA") {
         $blob .= "Windchill: <highlight>{$windchillstr}<end>\n";
     }
     $blob .= "Pressure: <highlight>{$pressurestr}<end>\n";
     $blob .= "Visibility: <highlight>{$visibilitymi} miles, {$visibilitykm} km<end>\n";
     $blob .= "Elevation: <highlight>{$elevation}<end>\n";
     // ALERTS
     $alertitems = xml::spliceMultiData($alerts, "<AlertItem>", "</AlertItem>");
     if (count($alertitems) == 0) {
         $blob .= "\n<header2>Alerts:<end> None reported.\n\n";
     } else {
         foreach ($alertitems as $thisalert) {
//.........这里部分代码省略.........
开发者ID:jibinam,项目名称:budabot2,代码行数:101,代码来源:WeatherController.class.php


注:本文中的xml::spliceMultiData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。