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


PHP io::helpers方法代码示例

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


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

示例1: content

 /**
  * Parses the content of the page.
  *
  * @return array
  */
 private static function content($content)
 {
     // Remove any JavaScript from the Content
     $content = preg_replace('/<script\\b[^>]*>(.*?)<\\/script>/is', ' ', $content);
     // Remove any in-line CSS from the Content
     $content = preg_replace('/<style\\b[^>]*>(.*?)<\\/style>/is', ' ', $content);
     // Ensure there are spaces between tags
     $content = str_replace('><', '> <', $content);
     // Remove the HTML tags from the Content while cleaning up whitespace
     $content = preg_replace('/\\s+/', ' ', strip_tags($content));
     // Remove special HTML characters
     $content = preg_replace('/&#?[a-z0-9]{2,8};/i', '', $content);
     // Get the list of SEO stop words
     $stopArr = \io::helpers('web')->stop_words();
     // Iterate through content and generate keyword usage
     foreach (explode(' ', $content) as $word) {
         /*
          * Normalize words (remove commas, colons, semi-colons, etc.) This also
          * casts integers as strings and ignores casing for words for SEO purposes.
          */
         $word = (string) strtolower(preg_replace("/[^A-Za-z0-9]/", '', $word));
         // Remove short words
         if (!isset($word[2])) {
             // Words 2 characters or less are excluded
             continue;
         }
         // Check if a word exists
         if (isset($keywords['Occurrence'][$word])) {
             // Increment the keyword count
             $keywords['Occurrence'][$word]++;
         } else {
             // Add the word
             $keywords['Occurrence'][$word] = 1;
         }
         // Check against SEO stop words
         if (!in_array($word, $stopArr)) {
             // Add to the SEO relevant keywords
             $keywords['SEO'][$word] = $keywords['Occurrence'][$word];
         }
     }
     // Check for content
     if (isset($keywords)) {
         // Sort Keywords by Occurrence
         arsort($keywords['Occurrence']);
         arsort($keywords['SEO']);
         // Top 10 keywords in order
         $keywords['Top'] = array_keys(array_slice($keywords['SEO'], 0, 10, true));
     } else {
         // No content
         $keywords = array('Occurrence' => array(), 'SEO' => array(), 'Top' => array());
     }
     // Normalize content
     $content = trim($content);
     // Check for empty content
     if ($content == '') {
         // Make developer friendly variable
         $content = false;
     }
     // Digest content
     return array('Content' => $content, 'Words' => str_word_count($content), 'Unique' => count($keywords['Occurrence']), 'Keywords' => $keywords);
 }
开发者ID:olscore,项目名称:ornithopter.io,代码行数:66,代码来源:crawler.php

示例2: tmp_password

 /**
  * Generate a temporary password.
  *
  * @return string
  */
 public static function tmp_password($length = 8)
 {
     // Random password from string helper
     return \io::helpers('str')->uuid($length);
 }
开发者ID:olscore,项目名称:ornithopter.io,代码行数:10,代码来源:security.php

示例3: slug

 /**
  * Returns a URL slug with or without SEO stop words removed.
  *
  * @param str
  * @param boolean
  *
  * @return str
  */
 public static function slug($str, $seo = false)
 {
     // Normalize the string
     $str = \io::helpers('str')->human(strtolower($str));
     // Optional SEO stop word removal
     if ($seo) {
         // Get a purified string
         $str = self::seo($str);
     }
     // Provide a title slug
     return str_replace(' ', '-', $str);
 }
开发者ID:olscore,项目名称:ornithopter.io,代码行数:20,代码来源:web.php


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