本文整理汇总了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);
}
示例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);
}
示例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);
}