本文整理汇总了PHP中str::condenseTags方法的典型用法代码示例。如果您正苦于以下问题:PHP str::condenseTags方法的具体用法?PHP str::condenseTags怎么用?PHP str::condenseTags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类str
的用法示例。
在下文中一共展示了str::condenseTags方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: str2metadesc
static function str2metadesc($txt)
{
$txt = str::condenseHtmlChars($txt, ' ');
$txt = str::condenseTags($txt, ' ');
$txt = str_replace(array('"', ' .'), array("'", '.'), $txt);
$txt = trim(str::condenseWhitespace($txt));
if (strlen($txt) > 320) {
$txt = substr($txt, 0, 317) . '...';
}
return $txt;
}
示例2: bodies2plain
private static function bodies2plain($bodies, $msgType)
{
$ret = '';
// clear html if both html and plain exist
if ($msgType == 'multipart/alternative') {
foreach ($bodies as $k => $i) {
if ($i['type'] == 'text/plain') {
$hasPlain = true;
}
}
if ($hasPlain) {
foreach ($bodies as $k => $i) {
if ($i['type'] == 'text/html') {
unset($bodies[$k]);
}
}
}
}
// condense bodies
foreach ($bodies as $part) {
// strip "=" at end of line
if ($part['encoding'] == 'quoted-printable') {
$part['body'] = quoted_printable_decode($part['body']);
}
// convert html to plain text
if ($part['type'] == 'text/html') {
// get html body element
$txt = str::between($part['body'], '<body>', '</body>', $pos = 0, true);
// improper html? just use the whole body part
if (!strlen($txt)) {
$txt = $part['body'];
}
// clean up
$txt = str::br2nl($txt);
$txt = trim(str::condenseTags($txt));
$txt = preg_replace('{[ \\t]+}', ' ', $txt);
$ret .= $txt;
} else {
$ret .= $part['body'];
}
}
return $ret;
}