插件10:文本简化
来源:互联网 发布:nginx jetty 区别 编辑:程序博客网 时间:2024/04/30 13:29
<?php // Plug-in 10: Shorten Text// This is an executable example with additional code supplied// To obtain just the plug-ins please click on the Download link$text = "http://rover.ebay.com/rover/1/711-53200-19255-0/1?type=3&campid=5336224516&toolid=10001&customid=tiny-hp&ext=unicycle&satitle=unicycle";echo "Before: <a href=\"$text\">$text</a><br /><br />";echo "After: <a href=\"$text\">" . PIPHP_ShortenText($text, 60, "/-/-/") . "</a>";function PIPHP_ShortenText($text, $size, $mark){ // Plug-in 10: Shorten Text // // This plug-in takes a string variable containing any // text and then shortens it to the length supplied by // removing text from the middle. The arguments required // are: // // $text: Text to be modified // $size: New size of the string // $mark: String to mark position of removed text $len = strlen($text); if ($size >= $len) return $text; $a = substr($text, 0, $size / 2 -1); $b = substr($text, $len - $size / 2 + 1, $size/ 2 -1); return $a . $mark . $b;}?>
插件说明:
插件10接受一个字符串变量,它代表一个需要简化的长URL地址(或其他字符串),返回简化后的URL地址,它需要用到以下参数:
$text 字符串变量,包含需要处理的文本
$size 数值变量,表示新字符串的大小
$mark 字符串变量,包含一个字符序列,标志字符串删除部分。
- 插件10:文本简化
- 简化版文本查询类
- 简化网站开发:SiteMesh插件
- 10款jQuery文本高亮插件
- 插件1:文本换行
- 插件19:GIF文本
- 插件35:文本验证
- 富文本插件 KindEditor
- 文本插件用法代码
- 富文本插件
- 文本编辑器插件
- 富文本插件推荐
- 使用 Linux 文本工具简化数据的提取
- 使用 Linux 文本工具简化数据的提取
- 10 简化几何计算
- 插件3:友好的文本
- Textarea - 富文本编辑器插件
- Textarea - 富文本编辑器插件
- 移动电子商务点击流参数文档- 手机埋点设计
- 插件9:去掉重音符号
- 面试题及答案
- asp.net mvc中ckeditor+ckfinder的配置方法
- 兔兔与老板的对话
- 插件10:文本简化
- C++静态成员函数
- hdu 1249 题答案详解
- android.os.handler
- C# iphone 开发环境的安装
- 卡特兰数
- 怎样让struts2的s:radio标签默认选中一个?
- 中国十大域名注册商
- struts action接收list对象