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


PHP parse_array函数代码示例

本文整理汇总了PHP中parse_array函数的典型用法代码示例。如果您正苦于以下问题:PHP parse_array函数的具体用法?PHP parse_array怎么用?PHP parse_array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: parse_array

function parse_array($arr)
{
    foreach ($arr as $key => $value) {
        $db = DB::select()->from('categories')->where('id', '=', $key)->execute();
        echo '<ul><li>';
        echo '<b>Название:</b> ' . form::input('name[]', $db[0]['name'], array('onkeyup' => 'translit(\'name[]\', \'url[]\');')) . form::hidden('cid[]', $db[0]['id']) . '&nbsp;';
        echo '<b>URL:</b> ' . form::input('url[]', $db[0]['url']) . '&nbsp;';
        echo '<b>Удалить?</b> ' . form::checkbox('delete[]', $db[0]['id']);
        echo '</li>';
        if (is_array($value)) {
            parse_array($value);
        }
        echo '</ul>';
    }
}
开发者ID:phpdude,项目名称:Purpled-Blog-Engine,代码行数:15,代码来源:categories.php

示例2: __construct

  function __construct($parse_text_k=null, $parse_text_v=null) {
    if(is_array($parse_text_k)) {
      $this->data=$parse_text_k;
    }
    elseif($parse_text_k==null) {
      $this->data=array();
    }
    else {
      $ks=parse_array($parse_text_k);
      $vs=parse_array($parse_text_v);

      $this->data=array();
      for($i=0; $i<sizeof($ks);$i++) {
	$this->data[$ks[$i]]=$vs[$i];
      }
    }
  }
开发者ID:plepe,项目名称:OpenStreetBrowser,代码行数:17,代码来源:tags.php

示例3: download_parse_rss

function download_parse_rss($target)
{
    # download tge rss page
    $news = http_get($target, "");
    # Parse title & copyright notice
    $rss_array['TITLE'] = return_between($news['FILE'], "<title>", "</title>", EXCL);
    $rss_array['COPYRIGHT'] = return_between($news['FILE'], "<copyright>", "</copyright>", EXCL);
    # Parse the items
    $item_array = parse_array($news['FILE'], "<item>", "</item>");
    for ($xx = 0; $xx < count($item_array); $xx++) {
        $rss_array['ITITLE'][$xx] = return_between($item_array[$xx], "<title>", "</title>", EXCL);
        $rss_array['ILINK'][$xx] = return_between($item_array[$xx], "<link>", "</link>", EXCL);
        $rss_array['IDESCRIPTION'][$xx] = return_between($item_array[$xx], "<description>", "</description>", EXCL);
        $rss_array['IPUBDATE'][$xx] = return_between($item_array[$xx], "<pubDate>", "</pubDate>", EXCL);
    }
    return $rss_array;
}
开发者ID:highestgoodlikewater,项目名称:PHPWebSpider,代码行数:17,代码来源:LIB_rss.php

示例4: get_encoding

function get_encoding($strHTML, $header = false)
{
    $enc = "";
    if ($header) {
        //try to pull encoding from header information
        $strHeader = substr($strHTML, 0, strpos($strHTML, "<"));
        //looking for line Content-Type: text/html; charset=utf-8
        $pos = strpos($strHeader, "charset=");
        if ($pos !== FALSE) {
            $pos2 = strpos($strHeader, "\n", $pos);
            $enc = substr($strHeader, $pos + 8, $pos2 - $pos - 8);
        }
    }
    #$head_section = return_between($string=$strHTML, $start="<head>", $end="</head>", $type=EXCL);
    # Create an array of all the meta tags
    $meta_tag_array = parse_array($strHTML, $beg_tag = "<meta", $close_tag = ">");
    $new_page = "";
    # Examine each meta tag for a redirection command
    for ($xx = 0; $xx < count($meta_tag_array); $xx++) {
        # Look for http-equiv attribute
        $meta_attribute = get_attribute($meta_tag_array[$xx], $attribute = "http-equiv");
        #echo $meta_tag_array[$xx] . "\n";
        if (strtolower($meta_attribute) == "content-type") {
            #echo "HERE!";
            $new_page = return_between($meta_tag_array[$xx], $start = "charset", $end = ">", $type = EXCL);
            # Clean up URL
            $new_page = trim(str_replace("", "", $new_page));
            $new_page = str_replace("/", "", $new_page);
            $new_page = str_replace("=", "", $new_page);
            $new_page = str_replace("\"", "", $new_page);
            $new_page = str_replace("'", "", $new_page);
            $new_page = str_replace(" ", "", $new_page);
            break;
        }
    }
    if (strlen($enc) > 0 && strlen($new_page) > 0) {
        return $enc . "," . $new_page;
    } elseif (strlen($new_page) > 0) {
        return $new_page;
    } elseif (strlen($enc) > 0) {
        return $enc;
    } else {
        return "";
    }
}
开发者ID:kuko-mainroot,项目名称:phpWebCralwer,代码行数:45,代码来源:LIB_encoding.php

示例5: getInfo

 public function getInfo()
 {
     $rawInfo = self::getRaw($this->action, $this->ref, $this->data);
     //import('SHD.simple_html_dom');
     $infoArray = parse_array($rawInfo['FILE'], '<tr>', '</tr>');
     $tr = [];
     $this->page = end($infoArray);
     foreach ($infoArray as $k => $v) {
         $tb = parse_array($v, '<td', '</td>');
         $temp = get_attribute($tb[7], 'href');
         $temp = split_string($temp, 'proj_idDes=', AFTER, EXCL);
         $tb[7] = remove($tb[7], '<a', '>');
         $tb[7] = remove($tb[7], '</a', '>');
         $temp2 = $tb[7];
         $tb[7] = [];
         $tb[7][] = $temp2;
         $tb[7][] = $temp;
         $temp4 = get_attribute($tb[8], 'href');
         $temp4 = split_string($temp4, 'proj_idDes=', AFTER, EXCL);
         $tb[8] = remove($tb[8], '<a', '>');
         $tb[8] = remove($tb[8], '</a', '>');
         $temp3 = $tb[8];
         $tb[8] = [];
         $tb[8][] = $temp3;
         $tb[8][] = $temp4;
         $tr[] = $tb;
         //parse_array($v,'<td','</td>');
         //var_dump($tr);
     }
     /*
              [4]=> array(9) { [0]=> string(37) "3" [1]=> string(30) "信息" [2]=> string(49) "201510613089 " [3]=> string(78) "基于人体肢体语言的机械臂操控" [4]=> string(62) "15国家创新训练项目" [5]=> string(45) "张翠芳" [6]=> string(185) "20132235 刘炳楠
     20132312 覃勇杰
     20132230 李晓芳
     20132169 涂敏
     " [7]=> string(145) "查看 " [8]=> string(158) " 成果展" }
     */
     /*$html=new simple_html_dom();
             $html->load($rawInfo["FILE"]);
             //var_dump($html);
     //return $rawInfo;
             $infoArray = $html->find('tr');*/
     return $tr;
 }
开发者ID:XQ-quadrant,项目名称:gbCMS,代码行数:43,代码来源:SearchModel.class.php

示例6: harvest_links

function harvest_links($url)
{
    # Initialize
    global $DELAY;
    $link_array = array();
    # Get page base for $url
    $page_base = get_base_page_address($url);
    # Download webpage
    sleep($DELAY);
    $downloaded_page = http_get($url, "");
    $anchor_tags = parse_array($downloaded_page['FILE'], "<a", "</a>", EXCL);
    # Put http attributes for each tag into an array
    for ($xx = 0; $xx < count($anchor_tags); $xx++) {
        $href = get_attribute($anchor_tags[$xx], "href");
        $resolved_addres = resolve_address($href, $page_base);
        $link_array[] = $resolved_addres;
        echo "Harvested: " . $resolved_addres . " \n";
    }
    return $link_array;
}
开发者ID:kuko-mainroot,项目名称:phpWebCralwer,代码行数:20,代码来源:LIB_simple_spider.php

示例7: describe_zipcode

function describe_zipcode($zipcode)
{
    # Get required libraries and declare the target
    include "../util/LIB_http.php";
    include "../util/LIB_parse.php";
    $target = "http://www.schrenk.com/nostarch/webbots/zip_code_form.php";
    # Download the target
    $page = http_get($target, $ref = "");
    # Parse the session hidden tag from the downloaded page
    # <input type="hidden" name="session" value="xxxxxxxxxx">
    $session_tag = return_between($string = $page['FILE'], $start = "<input type=\"hidden\" name=\"session\"", $end = ">", $type = EXCL);
    # Remove the "'s and "value=" text to reveal the session value
    $session_value = str_replace("\"", "", $session_tag);
    $session_value = str_replace("value=", "", $session_value);
    # Submit the form
    $data_array['session'] = $session_value;
    $data_array['zipcode'] = $zipcode;
    $data_array['Submit'] = "Submit";
    $form_result = http_post_form($target, $ref = $target, $data_array);
    $landmark = "Information about " . $zipcode;
    $table_array = parse_array($form_result['FILE'], "<table", "</table>");
    for ($xx = 0; $xx < count($table_array); $xx++) {
        # Parse the table containing the parsing landmark
        if (stristr($table_array[$xx], $landmark)) {
            $ret['CITY'] = return_between($table_array[$xx], "CITY", "</tr>", EXCL);
            $ret['CITY'] = strip_tags($ret['CITY']);
            $ret['STATE'] = return_between($table_array[$xx], "STATE", "</tr>", EXCL);
            $ret['STATE'] = strip_tags($ret['STATE']);
            $ret['COUNTY'] = return_between($table_array[$xx], "COUNTY", "</tr>", EXCL);
            $ret['COUNTY'] = strip_tags($ret['COUNTY']);
            $ret['LATITUDE'] = return_between($table_array[$xx], "LATITUDE", "</tr>", EXCL);
            $ret['LATITUDE'] = strip_tags($ret['LATITUDE']);
            $ret['LONGITUDE'] = return_between($table_array[$xx], "LONGITUDE", "</tr>", EXCL);
            $ret['LONGITUDE'] = strip_tags($ret['LONGITUDE']);
        }
    }
    # Return the parsed data
    return $ret;
}
开发者ID:highestgoodlikewater,项目名称:PHPWebSpider,代码行数:39,代码来源:website_to_function_bot.php

示例8: index

 public function index()
 {
     include "application/libraries/LIB_http.php";
     include "application/libraries/LIB_parse.php";
     $ref = "http://www.wenku8.cn";
     $method = "GET";
     $this->load->model("insertmodel");
     $success = "Catch OK";
     for ($xx = 1; $xx < 1700; $xx++) {
         $target = 'http://www.wenku8.cn/wap/article/packshow.php?id=' . $xx . '&type=txtfull';
         $web_page = http_get($target, $ref);
         //novel_name
         $label = '<card';
         $meta_tag_array = parse_array($web_page['FILE'], $label, ">");
         $meta_tag_array = str_replace(" ", "", $meta_tag_array);
         $meta_tag_array = str_replace("-", "", $meta_tag_array);
         $meta_tag = split_string($meta_tag_array[0], "title=\"", AFTER, EXCL);
         $novel_name = strip_tags(split_string($meta_tag, "TXT", BEFORE, EXCL));
         //update_time
         preg_match_all("/\\d{4}-\\d{1,2}-\\d{1,2}/", @$web_page['FILE'], $matches_array);
         foreach ($matches_array[0] as $key => $value) {
             $update_time = $value;
         }
         echo $update_time;
         //size
         preg_match_all("/\\d+K/", @$web_page['FILE'], $get_array);
         foreach ($get_array[0] as $key => $value) {
             $size = $value;
         }
         $data = array('novel_id' => $xx, 'novel_name' => empty($novel_name) ? '没有这本小说' : $novel_name, 'update_time' => $update_time, 'size' => $size . K);
         //print_r($data);
         echo "<br>";
         $this->insertmodel->insert_Novel($data);
         //echo $data;
     }
     $this->load->view('curl_result', $success);
 }
开发者ID:highestgoodlikewater,项目名称:Omoikane,代码行数:37,代码来源:curl.php

示例9: curl_setopt

    curl_setopt($ch, CURLOPT_REFERER, $file);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($ch, CURLOPT_MAXREDIRS, 4);
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}
$result = array();
$url = filter_input(INPUT_POST, "input-link");
$last_position = strripos($url, '/');
$last_position += 1;
$url_dir = substr($url, 0, $last_position);
$web_page = http_get($url, $ref = "");
$web_page = $web_page["FILE"];
$a_tag = parse_array($web_page, "<a ", ">");
$count = 0;
foreach ($a_tag as $val) {
    if (stristr($val, "playAudioBarPlay")) {
        $href_str = trim(get_attribute($val, "href"));
        $href_str = str_replace("'", "", $href_str);
        $href_str = str_replace("(", "", $href_str);
        $href_str = str_replace(")", "", $href_str);
        $href_arr = explode(",", $href_str);
        $href_str = str_replace("javascript:playAudioBarPlay", "", $href_arr[0]);
        if (!file_exists("audio/" . $href_str)) {
            $audio_file = download_audio($url_dir . 'aumpo/' . $href_str);
            file_put_contents("audio/" . $href_str, $audio_file);
            $file_size = filesize("audio/" . $href_str, $audio_file);
            if ($file_size === false || $file_size <= 0) {
                $result["result"] = "error download audio form link";
开发者ID:peter279k,项目名称:coscom,代码行数:31,代码来源:index.php

示例10: http_get

COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF 
ANY USE OF THE SOFTWARE OR DOCUMENTATION.

The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the 
software without specific, written prior permission. Title to copyright in this software and any associated 
documentation will at all times remain with copyright holders.

Copyright 2007, Michael Schrenk

THIS SCRIPT IS FOR DEMONSTRATION PURPOSES ONLY! 
    It is not suitable for any use other than demonstrating 
    the concepts presented in Webbots, Spiders and Screen Scrapers. 
########################################################################
*/
?>



<?php 
#PHP_LIBRARY_PATH
$PHP_LIBRARY_PATH = "../phplibs";
include "{$PHP_LIBRARY_PATH}/LIB_parse.php";
# Include parse library
include "{$PHP_LIBRARY_PATH}/LIB_http.php";
# Include cURL library
$web_page = http_get($target = "http://www.fbi.gov", $referer = "");
$meta_tag_array = parse_array($web_page['FILE'], "<meta", ">");
for ($xx = 0; $xx < count($meta_tag_array); $xx++) {
    echo $meta_tag_array[$xx] . "\n";
}
开发者ID:redhero0702,项目名称:scriptforFAE,代码行数:30,代码来源:LISTING_4_6.php

示例11: parse_array

 function parse_array($arr)
 {
     if (is_array($arr)) {
         //folder/clip
         foreach ($arr as $name => $sub_arr) {
             if ($name != $sub_arr['name']) {
                 //folder
                 echo "<a onclick='Toggle(this);' style='display: block; cursor: pointer; text-decoration: none;'><img src='resources/images/icon_folder.png' border='none' align='absmiddle' style='margin: 1px 2px 3px 0px;'>" . $name . "</a>";
                 echo "<div style='display: none; padding-left: 16px;'>\n";
                 parse_array($sub_arr);
                 echo "</div>\n";
             } else {
                 //clip
                 echo "<div style='white-space: nowrap;'>\n";
                 echo "<a href='javascript:void(0);' onclick=\"parent.document.getElementById('clip_uuid').value='" . $sub_arr['uuid'] . "'; parent.document.getElementById('clip_name').value='" . $sub_arr['name'] . "';\">";
                 echo "<img src='resources/images/icon_file.png' border='0' align='absmiddle' style='margin: 1px 2px 3px -1px;'>";
                 echo $sub_arr['name'];
                 echo "</a>\n";
                 echo "<textarea style='display: none' id='before_" . $sub_arr['uuid'] . "'>" . $sub_arr['before'] . "</textarea>\n";
                 echo "<textarea style='display: none' id='after_" . $sub_arr['uuid'] . "'>" . $sub_arr['after'] . "</textarea>\n";
                 echo "</div>\n";
             }
         }
     }
 }
开发者ID:kpabijanskas,项目名称:fusionpbx,代码行数:25,代码来源:clipoptionslist.php

示例12: download_images_for_page

function download_images_for_page($target)
{
    echo "target = {$target}\n";
    # Download the web page
    $web_page = http_get($target, $referer = "");
    # Update the target in case there was a redirection
    $target = $web_page['STATUS']['url'];
    # Strip file name off target for use as page base
    $page_base = get_base_page_address($target);
    # Identify the directory where iamges are to be saved
    $save_image_directory = "saved_images_" . str_replace("http://", "", $page_base);
    # Parse the image tags
    $img_tag_array = parse_array($web_page['FILE'], "<img", ">");
    if (count($img_tag_array) == 0) {
        echo "No images found at {$target}\n";
        exit;
    }
    # Echo the image source attribute from each image tag
    for ($xx = 0; $xx < count($img_tag_array); $xx++) {
        $image_path = get_attribute($img_tag_array[$xx], $attribute = "src");
        echo " image: " . $image_path;
        $image_url = resolve_address($image_path, $page_base);
        if (get_base_domain_address($page_base) == get_base_domain_address($image_url)) {
            # Make image storage directory for image, if one doesn't exist
            $directory = substr($image_path, 0, strrpos($image_path, "/"));
            $directory = str_replace(":", "-", $directory);
            $image_path = str_replace(":", "-", $image_path);
            clearstatcache();
            // clear cache to get accurate directory status
            if (!is_dir($save_image_directory . "/" . $directory)) {
                mkpath($save_image_directory . "/" . $directory);
            }
            # Download the image, report image size
            $this_image_file = download_binary_file($image_url, $ref = "");
            echo " size: " . strlen($this_image_file);
            # Save the image
            if (stristr($image_url, ".jpg") || stristr($image_url, ".gif") || stristr($image_url, ".png")) {
                $fp = fopen($save_image_directory . "/" . $image_path, "w");
                fputs($fp, $this_image_file);
                fclose($fp);
                echo "\n";
            }
        } else {
            echo "\nSkipping off-domain image.\n";
        }
    }
}
开发者ID:peter279k,项目名称:store_photo,代码行数:47,代码来源:LIB_download_images.php

示例13: __construct

 function __construct($data) {
   parent::__construct($data);
   if(is_string($this->data[member_ids])) {
     $this->data[member_ids]=parse_array($this->data[member_ids]);
     $this->data[member_roles]=parse_array($this->data[member_roles]);
     load_objects($this->data[member_ids]);
     foreach($this->data[member_ids] as $i=>$mem) {
       $obj=load_object($mem);
       $this->members[]=array($obj, $this->data[member_roles][$i]);
     }
   }
 }
开发者ID:plepe,项目名称:OpenStreetBrowser,代码行数:12,代码来源:place.php

示例14: array

 $indirectTotalIndirectRouteDistanceArray = array();
 $indirectTotalRouteDistanceArray = array();
 $numRouteCount = 0;
 //parse the routes
 foreach ($routes as $route) {
     $numRouteCount++;
     $indirectRouteErrorCodeArray = parse_array($indirectRoute, "<ErrorCode>", "</ErrorCode>");
     $indirectStartStopsArray = parse_array($indirectRoute, "<StartStop>", "</StartStop>");
     $indirectStartBusesArray = parse_array($indirectRoute, "<StartBuses>", "</StartBuses>");
     $indirectFirstJunctionsArray = parse_array($indirectRoute, "<FirstJunction>", "</FirstJunction>");
     $indirectDistanceBetweenJunctionArray = parse_array($indirectRoute, "<DistanceBetweenJunction>", "</DistanceBetweenJunction>");
     $indirectSecondJunctionsArray = parse_array($indirectRoute, "<SecondJunction>", "</SecondJunction>");
     $indirectEndBusesArray = parse_array($indirectRoute, "<EndBuses>", "</EndBuses>");
     $indirectEndStopsArray = parse_array($indirectRoute, "<EndStop>", "</EndStop>");
     $indirectTotalIndirectRouteDistanceArray = parse_array($indirectRoute, "<TotalIndirectRouteDistance>", "</TotalIndirectRouteDistance>");
     $indirectTotalRouteDistanceArray = parse_array($indirectRoute, "<TotalRouteDistance>", "</TotalRouteDistance>");
 }
 for ($i = 0; $i < $numRouteCount; $i++) {
     if ($i == 0) {
         echo "StartStop:" . $startStop . "," . "EndStop:" . $endStop . ",depotErrorCode:" . intval($depotErrorCode) . "n";
     }
     echo "<br/>";
     //echo "Route#".$i;
     echo "ErrorCode:" . intval(return_between($indirectRouteErrorCodeArray[$i], "<ErrorCode>", "</ErrorCode>", EXCL)) . "\t";
     //echo "StartStop:".$indirectStartStopsArray[$i]."\t";
     //echo "StartBuses:".$indirectStartBusesArray[$i]."\t";
     //echo "FirstJunction:".$indirectFirstJunctionsArray[$i]."\t";
     echo "DistanceBetweenJucntion:" . $indirectDistanceBetweenJunctionArray[$i] . "\t";
     //echo "SecondJunction:".$indirectSecondJunctionsArray[$i]."\t";
     //echo "EndBuses:".$indirectEndBusesArray[$i]."\t";
     //echo "EndStop:".$indirectEndStopsArray[$i]."\t";
开发者ID:rohdimp24,项目名称:test,代码行数:31,代码来源:fetchInfoFromXMLFiles.php

示例15: http_get




<?php 
# Inlcude http and parse libraries
include "../util/LIB_http_browser.php";
include "../util/LIB_parse.php";
include "../util/LIB_resolve_addresses.php";
include "../util/LIB_http_codes.php";
# Identify the target web page and the page base
$target = "http://www.schrenk.com/nostarch/webbots/page_with_broken_links.php";
$page_base = "http://www.schrenk.com/nostarch/webbots/";
# Download the web page
$downloaded_page = http_get($target, $ref = "");
# Parse the links
$link_array = parse_array($downloaded_page['FILE'], $beg_tag = "<a", $close_tag = ">");
# Verify the links
?>
<table border="1" cellpadding="1" cellspacing="0">
    <tr bgcolor="#e0e0e0">
        <th>URL</th>
        <th>HTTP CODE</th>
        <th>DOWNLOAD TIME (seconds)</th>
    </tr>
<?php 
for ($xx = 0; $xx < count($link_array); $xx++) {
    // Parse the http attribute from link
    $link = get_attribute($tag = $link_array[$xx], $attribute = "href");
    // Create a fully resolved address
    $resloved_link_address = resolve_address($link, $page_base);
    $downloaded_link = http_get($resloved_link_address, $target);
开发者ID:highestgoodlikewater,项目名称:PHPWebSpider,代码行数:28,代码来源:link_verification_bot.php


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