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


PHP SimplePie_Misc::entities_decode方法代码示例

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


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

示例1: get_element

 /**
  * Get a HTML/XML element from a HTML string
  *
  * @deprecated Use DOMDocument instead (parsing HTML with regex is bad!)
  * @param string $realname Element name (including namespace prefix if applicable)
  * @param string $string HTML document
  * @return array
  */
 public static function get_element($realname, $string)
 {
     $return = array();
     $name = preg_quote($realname, '/');
     if (preg_match_all("/<({$name})" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . "(>(.*)<\\/{$name}>|(\\/)?>)/siU", $string, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) {
         for ($i = 0, $total_matches = count($matches); $i < $total_matches; $i++) {
             $return[$i]['tag'] = $realname;
             $return[$i]['full'] = $matches[$i][0][0];
             $return[$i]['offset'] = $matches[$i][0][1];
             if (strlen($matches[$i][3][0]) <= 2) {
                 $return[$i]['self_closing'] = true;
             } else {
                 $return[$i]['self_closing'] = false;
                 $return[$i]['content'] = $matches[$i][4][0];
             }
             $return[$i]['attribs'] = array();
             if (isset($matches[$i][2][0]) && preg_match_all('/[\\x09\\x0A\\x0B\\x0C\\x0D\\x20]+([^\\x09\\x0A\\x0B\\x0C\\x0D\\x20\\x2F\\x3E][^\\x09\\x0A\\x0B\\x0C\\x0D\\x20\\x2F\\x3D\\x3E]*)(?:[\\x09\\x0A\\x0B\\x0C\\x0D\\x20]*=[\\x09\\x0A\\x0B\\x0C\\x0D\\x20]*(?:"([^"]*)"|\'([^\']*)\'|([^\\x09\\x0A\\x0B\\x0C\\x0D\\x20\\x22\\x27\\x3E][^\\x09\\x0A\\x0B\\x0C\\x0D\\x20\\x3E]*)?))?/', ' ' . $matches[$i][2][0] . ' ', $attribs, PREG_SET_ORDER)) {
                 for ($j = 0, $total_attribs = count($attribs); $j < $total_attribs; $j++) {
                     if (count($attribs[$j]) === 2) {
                         $attribs[$j][2] = $attribs[$j][1];
                     }
                     $return[$i]['attribs'][strtolower($attribs[$j][1])]['data'] = SimplePie_Misc::entities_decode(end($attribs[$j]));
                 }
             }
         }
     }
     return $return;
 }
开发者ID:kadrim1,项目名称:metsayhistu,代码行数:36,代码来源:Misc.php

示例2: get_element

 function get_element($realname, $string)
 {
     $return = array();
     $name = preg_quote($realname, '/');
     if (preg_match_all("/<({$name})" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . "(>(.*)<\\/{$name}>|(\\/)?>)/siU", $string, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) {
         for ($i = 0, $total_matches = count($matches); $i < $total_matches; $i++) {
             $return[$i]['tag'] = $realname;
             $return[$i]['full'] = $matches[$i][0][0];
             $return[$i]['offset'] = $matches[$i][0][1];
             if (strlen($matches[$i][3][0]) <= 2) {
                 $return[$i]['self_closing'] = true;
             } else {
                 $return[$i]['self_closing'] = false;
                 $return[$i]['content'] = $matches[$i][4][0];
             }
             $return[$i]['attribs'] = array();
             if (!empty($matches[$i][2][0]) && preg_match_all('/((?:[^\\s:]+:)?[^\\s:]+)(?:\\s*=\\s*(?:"([^"]*)"|\'([^\']*)\'|([a-z0-9\\-._:]*)))?\\s/U', ' ' . $matches[$i][2][0] . ' ', $attribs, PREG_SET_ORDER)) {
                 for ($j = 0, $total_attribs = count($attribs); $j < $total_attribs; $j++) {
                     if (count($attribs[$j]) == 2) {
                         $attribs[$j][2] = $attribs[$j][1];
                     }
                     $return[$i]['attribs'][strtolower($attribs[$j][1])]['data'] = SimplePie_Misc::entities_decode(end($attribs[$j]), 'UTF-8');
                 }
             }
         }
     }
     return $return;
 }
开发者ID:searchfirst,项目名称:Lenore,代码行数:28,代码来源:simplepie.php


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