位置: 编程技术 - 正文

PHP:mb_ereg_replace_callback()的用法_mbstring函数

编辑:rootadmin
mb_ereg_replace_callback

推荐整理分享PHP:mb_ereg_replace_callback()的用法_mbstring函数,希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:,内容如对您有帮助,希望把文章链接给更多的朋友!

(PHP 5 >= 5.4.1)

mb_ereg_replace_callback — Perform a regular expresssion seach and replace with multibyte support using a callback

说明 string mb_ereg_replace_callback ( string $pattern , callable $callback , string $string [, string $option = "msr" ] )

Scans string for matches to pattern, then replaces the matched text with the output of callback function.

The behavior of this function is almost identical to mb_ereg_replace(), except for the fact that instead of replacement parameter, one should specify a callback.

参数

pattern

The regular expression pattern.

Multibyte characters may be used in pattern.

callback

A callback that will be called and passed an array of matched elements in the subject string. The callback should return the replacement string.

You&#;ll often need the callback function for a mb_ereg_replace_callback() in just one place. In this case you can use an anonymous function to declare the callback within the call to mb_ereg_replace_callback(). By doing it this way you have all information for the call in one place and do not clutter the function namespace with a callback function&#;s name not used anywhere else.

string PHP:mb_ereg_replace_callback()的用法_mbstring函数

The string being checked.

option

Matching condition can be set by option parameter. If i is specified for this parameter, the case will be ignored. If x is specified, white space will be ignored. If m is specified, match will be executed in multiline mode and line break will be included in &#;.&#;. If p is specified, match will be executed in POSIX mode, line break will be considered as normal character. Note that e cannot be used for mb_ereg_replace_callback().

返回值

The resultant string on success, or FALSE on error.

注释

Note:

mb_regex_encoding()指定的内部编码或字符编码将会当作此函数用的字符编码。

范例

Example #1 mb_ereg_replace_callback() example

<?php//thistextwasusedin//wewanttogetthisuptodatefor$text="Aprilfoolsdayis//n";$text.="Lastchristmaswas//n";//thecallbackfunctionfunctionnext_year($matches){//asusual:$matches[0]isthecompletematch//$matches[1]thematchforthefirstsubpattern//enclosedin'(...)'andsoonreturn$matches[1].($matches[2]+1);}echomb_ereg_replace_callback("(d{2}/d{2}/)(d{4})","next_year",$text);?>

以上例程会输出:

Example #2 mb_ereg_replace_callback() using anonymous function supported in PHP 5.3.0 or later

<?php//thistextwasusedin//wewanttogetthisuptodatefor$text="Aprilfoolsdayis//n";$text.="Lastchristmaswas//n";echomb_ereg_replace_callback("(d{2}/d{2}/)(d{4})",function($matches){return$matches[1].($matches[2]+1);},$text);?>

参见

mb_regex_encoding() - Set/Get character encoding for multibyte regex mb_ereg_replace() - Replace regular expression with multibyte support Anonymous functions callback 类型的信息

PHP:mb_ereg_search_getregs()的用法_mbstring函数 mb_ereg_search_getregs(PHP4=4.2.0,PHP5)mb_ereg_search_getregsRetrievetheresultfromthelastmultibyteregularexpressionmatch说明arraymb_ereg_search_getregs(void)Retrievetheresultfromthelastmultibyteregu

PHP:mb_ereg_search_getpos()的用法_mbstring函数 mb_ereg_search_getpos(PHP4=4.2.0,PHP5)mb_ereg_search_getposReturnsstartpointfornextregularexpressionmatch说明intmb_ereg_search_getpos(void)Returnsthestartpointforthenextregularexpressionmatch.参数

PHP:mb_encode_numericentity()的用法_mbstring函数 mb_encode_numericentity(PHP4=4.0.6,PHP5)mb_encode_numericentityEncodecharactertoHTMLnumericstringreference说明stringmb_encode_numericentity(string$str,array$convmap[,string$encoding=mb_internal_enco

标签: PHP:mb_ereg_replace_callback()的用法_mbstring函数

本文链接地址:https://www.jiuchutong.com/biancheng/275028.html 转载请保留说明!

上一篇:PHP:mb_ereg_replace()的用法_mbstring函数

下一篇:PHP:mb_ereg_search_getregs()的用法_mbstring函数

  • 增值税专用发票抵扣最新规定
  • 未交增值税借贷方负数表示
  • 税点是什么费用
  • 分税制财政管理体制是什么?
  • 纳税申报表保留几年
  • 工会经费余额在借方怎么办
  • 存货占营业收入的意义
  • 甲公司自2018年3月1日开始自行研发一款新兴产品
  • 会计分录怎么确认借贷方向
  • 服装行业营业收入存在的问题与对策
  • 自建厂房销售
  • 年底结账时利息收入怎么做处理?
  • 技术服务费发票税率是多少
  • 机动车发票如何抵扣进项税
  • 营改增后房屋租赁如何纳税
  • 应收账款挂账要开票吗
  • 营改增后建筑业分包怎么交税
  • 销售蔬菜免税账务处理
  • 未抵扣增值税入什么科目
  • 公积金超出上限部分
  • 房产税怎么做账
  • 酒精是否属于消费税征税范围
  • 餐查账征收企业所得税会计分录?
  • 事业单位财政拨款是什么意思
  • 建厂房的费用怎么记账
  • win11隐藏图标怎么弄出来
  • 企业废业怎样做会计分录
  • 季度资产总额怎么填写
  • 如何做会计分录
  • 认筹金客户经常提出哪些问题
  • 鸿蒙系统怎么隐藏状态栏
  • mac修改系统版本号
  • 月末季末年末会计都需要做什么
  • thinkphp5上传图片
  • 免税的农业企业可以抵扣专票吗
  • php实现文件的下载
  • thinkphp3.1
  • 固定资产没有发票可以计提折旧吗
  • typescript类型别名
  • python3.9.4怎么用
  • python爬虫入门教程
  • php自定义函数实现计算整数的四次方
  • 7z命令行详解
  • 劳务公司怎么申请办理
  • g郭敬明
  • 帝国cms好用吗
  • 企业研发费用的优惠政策
  • SQL Server 2008 R2 超详细安装图文教程
  • 减免税的三种方式
  • 工程一般挂靠取得的收入怎么做账?
  • 增值税不超过30万,普通发票可以开0税率吗
  • 电子发票不小心删掉了怎么办
  • 开具其他发票收入填报异常
  • 计提工资发工资可做成一笔账吗
  • 政府会计准则具体准则的作用
  • sql Server 触发器的when的用法
  • mysql闪退怎么回事
  • win8系统没有无线网络连接
  • linux中samba服务器的设计方案
  • fedora怎么用
  • 电脑系统停用
  • linux计划任务怎么写
  • win7winxp双系统怎么装
  • win10 打开文件
  • w10消费者版本和专业版区别
  • linux手动设置ip指令
  • msxct.exe - msxct是什么进程 有什么用
  • win10 mobile 1709
  • linuxvim编辑器的用法
  • linux入门学习
  • 怎么对js代码程序进行设计
  • 深入理解
  • shell(bash)下“time” 命令的输出详解
  • jquery设计模式
  • mybatis框架执行流程
  • ajax+node+request爬取网络图片的实例(宅男福利)
  • python编写api接口
  • android刷题
  • 山东网上信访投诉平台
  • 工会活动经费的请示
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设