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


PHP nnText::getAttributes方法代码示例

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


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

示例1: combineAttributes

 /**
  * combine attribute values in a tag string
  */
 public static function combineAttributes($string1, $string2)
 {
     $attribs1 = is_array($string1) ? $string1 : nnText::getAttributes($string1);
     $attribs2 = is_array($string2) ? $string2 : nnText::getAttributes($string2);
     $dublicate_attribs = array_intersect_key($attribs1, $attribs2);
     // Fill $attribs with the unique ids
     $attribs = array_diff_key($attribs1, $attribs2) + array_diff_key($attribs2, $attribs1);
     // Add/combine the duplicate ids
     $single_value_attributes = array('id', 'href');
     foreach ($dublicate_attribs as $key => $val) {
         if (in_array($key, $single_value_attributes)) {
             $attribs[$key] = $attribs2[$key];
             continue;
         }
         // Combine strings, but remove duplicates
         // "aaa bbb" + "aaa ccc" = "aaa bbb ccc"
         // use a ';' as a concatenated for javascript values (keys beginning with 'on')
         $glue = substr($key, 0, 2) == 'on' ? ';' : ' ';
         $attribs[$key] = implode($glue, array_merge(explode($glue, $attribs1[$key]), explode($glue, $attribs2[$key])));
     }
     foreach ($attribs as $key => &$val) {
         $val = $key . '="' . $val . '"';
     }
     return implode(' ', $attribs);
 }
开发者ID:smart-one,项目名称:3kita,代码行数:28,代码来源:text.php

示例2: combineAttributes

 /**
  * combine attribute values in a tag string
  */
 public static function combineAttributes($string1, $string2)
 {
     $attribs1 = is_array($string1) ? $string1 : nnText::getAttributes($string1);
     $attribs2 = is_array($string2) ? $string2 : nnText::getAttributes($string2);
     $dublicate_attribs = array_intersect_key($attribs1, $attribs2);
     // Fill $attribs with the unique ids
     $attribs = array_diff_key($attribs1, $attribs2) + array_diff_key($attribs2, $attribs1);
     // Add/combine the duplicate ids
     $single_value_attributes = array('id');
     foreach ($dublicate_attribs as $key => $val) {
         if (in_array($key, $single_value_attributes)) {
             $attribs[$key] = $attribs2[$key];
             continue;
         }
         // Combine strings, but remove duplicates
         // "aaa bbb" + "aaa ccc" = "aaa bbb ccc"
         $attribs[$key] = implode(' ', explode(' ', $attribs1[$key]) + explode(' ', $attribs2[$key]));
     }
     foreach ($attribs as $key => &$val) {
         $val = $key . '="' . $val . '"';
     }
     return implode(' ', $attribs);
 }
开发者ID:WineWorld,项目名称:joomlatrialcmbg,代码行数:26,代码来源:text.php


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