當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。