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


PHP http::table_into_array方法代码示例

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


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

示例1: getQuoteData

/** Function to get company quotes from external site
 * @param $var -- var:: Type string(company trickersymbol)
 * @returns $quote_data -- quote_data:: Type string array
 *
 */
function getQuoteData($var)
{
    $url = "http://finance.yahoo.com/q?s=" . $var;
    $h = new http();
    $h->dir = "class_http_dir/";
    if (!$h->fetch($url, 2)) {
        echo "<h2>There is a problem with the http request!</h2>";
        echo $h->log;
        exit;
    }
    $res_arr = array();
    $quote_data = http::table_into_array($h->body, 'Delayed quote data', 0, null);
    if (is_array($quote_data)) {
        array_shift($quote_data);
        array_shift($quote_data);
        if ($quote_data[0][0] != 'Last Trade:') {
            array_shift($quote_data);
        }
    } else {
        die;
    }
    for ($i = 0; $i < 16; $i++) {
        if ($quote_data != '') {
            $res_arr[] = $quote_data[$i];
        }
    }
    return $res_arr;
}
开发者ID:casati-dolibarr,项目名称:corebos,代码行数:33,代码来源:getCompanyProfile.php

示例2: table_into_xml

 function table_into_xml($rawHTML, $needle = "", $needle_within = 0, $allowedTags = "")
 {
     if (!($aryTable = http::table_into_array($rawHTML, $needle, $needle_within, $allowedTags))) {
         return false;
     }
     $xml = "<?xml version=\"1.0\" standalone=\"yes\" \\?\\>\n";
     $xml .= "<TABLE>\n";
     $rowIdx = 0;
     foreach ($aryTable as $row) {
         $xml .= "\t<ROW id=\"" . $rowIdx . "\">\n";
         $colIdx = 0;
         foreach ($row as $col) {
             $xml .= "\t\t<COL id=\"" . $colIdx . "\">" . trim(utf8_encode(htmlspecialchars($col))) . "</COL>\n";
             $colIdx++;
         }
         $xml .= "\t</ROW>\n";
         $rowIdx++;
     }
     $xml .= "</TABLE>";
     return $xml;
 }
开发者ID:YaleMakes,项目名称:HumanEcosystems,代码行数:21,代码来源:class_http.php

示例3: table_into_array

}
/* Echo out the body content fetched from the url. */
echo $h->body;
/*
Extract a specific table of data out of scraped content. The class
comes with 2 static methods you can use for this purpose.
  table_into_array() will rip a single table into an array.
  table_into_xml() will internally call table_into_array() then create an 
  XML document from the array. I thought this would be cool, but in practice,
  I've never used this method since the array is so easy to work with.

This example builds on the previous example to extract the MSFT stats out
of the body content. Read the comments in the class file to learn how to use
this static method.
*/
$msft_stats = http::table_into_array($h->body, "Avg Daily Volume", 1, null);
/* Print out the array so you can see the stats data. */
echo "<pre>";
print_r($msft_stats);
echo "</pre>";
/*
Scraping content that is username/password protected. The class can do basic
authentication. Pass your username and password in like this:
*/
$url = "http://someprivatesite.net";
$h->fetch($url, 0, null, "MyUserName", "MyPassword");
/*
If your need to access content on a port other than 80, just put the port in
the URL in the standard way:
*/
$h->fetch("http://somedomain.org:8088");
开发者ID:HaakonME,项目名称:porticoestate,代码行数:31,代码来源:example.php


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