本文整理汇总了PHP中NNText::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP NNText::toArray方法的具体用法?PHP NNText::toArray怎么用?PHP NNText::toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NNText
的用法示例。
在下文中一共展示了NNText::toArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRegexTags
public static function getRegexTags($tags, $include_no_attributes = true, $include_ending = true, $required_attributes = array())
{
require_once __DIR__ . '/text.php';
$tags = NNText::toArray($tags);
$tags = count($tags) > 1 ? '(?:' . implode('|', $tags) . ')' : $tags['0'];
$spaces = self::getRegexSpaces();
$attribs = $spaces . '[^>"]*(?:"[^"]*"[^>"]*)+';
$required_attributes = NNText::toArray($required_attributes);
if (!empty($required_attributes)) {
$attribs = $spaces . '[^>"]*(?:"[^"]*"[^>"]*)*(?:' . implode('|', $required_attributes) . ')\\s*=\\s*(?:"[^"]*"[^>"]*)+';
}
if ($include_no_attributes) {
$attribs = '(?:' . $attribs . ')?';
}
if (!$include_ending) {
return '<' . $tags . $attribs . '>';
}
return '<(?:\\/' . $tags . '|' . $tags . $attribs . ')(?:\\/|' . $spaces . ')*>';
}
示例2: getRegexTags
public static function getRegexTags($tags, $include_no_attributes = true, $include_ending = true, $required_attributes = array())
{
require_once __DIR__ . '/text.php';
$tags = NNText::toArray($tags);
$tags = count($tags) > 1 ? '(?:' . implode('|', $tags) . ')' : $tags['0'];
$value = '(?:\\s*=\\s*(?:"[^"]*"|\'[^\']*\'|[a-z0-9-_]+))?';
$attribs = '(?:\\s+[a-z0-9-_]+' . $value . ')+';
$required_attributes = NNText::toArray($required_attributes);
if (!empty($required_attributes)) {
$attribs = $attribs . '(?:\\s+' . implode('|', $required_attributes) . ')' . $value . $attribs;
}
if ($include_no_attributes) {
$attribs = '\\s*(?:' . $attribs . ')?';
}
if (!$include_ending) {
return '<' . $tags . $attribs . '\\s*>';
}
return '<(?:\\/' . $tags . '|' . $tags . $attribs . '\\s*/?)\\s*>';
}