位置: 编程技术 - 正文

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函数

  • 划转国有划拨土地要交契税吗?
  • 收取境外服务费收入如何开票
  • 出口报关单价比合同价高
  • 人工费用的核算例题
  • 美元利息结汇时结汇项目是什么
  • 文化传媒公司开票税点
  • 小规模纳税人30万含专票吗
  • 预付款与定金的比例
  • 工会的会费收入如何记账
  • 上年度没有计提企业所得税
  • 供应商租赁企业资质要求
  • 个人所得税多缴了可以退回吗
  • 民办幼儿园需要给老师交五险一金吗
  • 2016年的发票2019年还能开红字吗
  • 关于增值税报税的通知
  • 还在讨论“税务金四”上线?税务和银行要联手清查单位和个人账户了!
  • 按季申报是什么意思
  • 在建工程的折旧费计入什么科目
  • 未分配利润期末余额怎么算出来
  • 债务免除的税务处理
  • 销售自建的不动产如何缴纳增值税
  • 资产折旧出现负数
  • 跨期费用会计处理
  • 不动产进项抵扣新政策2022
  • 进项认证转出 会计得入账吗
  • 办理出口退税的流程
  • 主板外部接口是用来连接
  • 苹果6手机锁屏
  • PSof1.exe - PSof1是什么进程 有什么作用
  • 软件测评费用标准
  • 两台mac怎么一起用
  • php自学教程
  • linux获取操作命令的使用方法
  • 房产公司财务工作内容
  • 电商平台第三方服务
  • 高新企业研发费用比例
  • 待摊费用计入哪里
  • PHP:ftp_rename()的用法_FTP函数
  • 增值税专用发票有几联?
  • dm分区工具图解教程
  • ati2plab.exe是什么进程 ati2plab进程安全吗
  • 发财树的养殖方法和浇水时间
  • php如何自定义函数
  • 小规模纳税人的企业所得税税率
  • 生产企业计提车折旧年限
  • e命令怎么用
  • 原始投资额的现值
  • 数据库 sql优化
  • vue获取dom元素的方法
  • 个税赡养老人作废后无法修改
  • 发票认证后总局没信息
  • 没有虚拟化iommu
  • 三免三减半税收政策中的递延所得税
  • 单位买车和个人买车交税有何不同
  • 增值税红字发票怎么填开
  • 企业支付的费用化的一般借款利息支出属于什么
  • 房租没有发票如何处理
  • 通行费电子发票进项税额如何填报
  • 企业收到拆迁补偿款
  • 医院工会费是什么
  • 银行手续费发票未到怎样做账
  • 金税盘每年服务费可以抵扣吗
  • 信托保障基金会返还吗
  • 加油卡充值发票可以抵税吗
  • 股东股权转让会计分录
  • appcrash是什么文件
  • android系统应用可以禁用吗
  • host文件内容
  • 远程关机对话框怎么打开
  • linux me
  • cocos2dx4.0教程
  • JavaScript的instanceof运算符学习教程
  • 后台运行bat定时器程序示例分享
  • jquery绑定keyup
  • 西安国家税务局丁雁现任命职务
  • 电子三方协议怎么下载
  • 运输类税点
  • 上海房产税免税面积怎么算
  • 四川省地方税务局关于城镇土地使用税困难减免
  • 地方税务局是事业单位吗
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设