位置: 编程技术 - 正文

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

  • 吸收合并的税务问题
  • 应交增值税月末出现借方余额怎么处理
  • aisino金税盘怎么安装在电脑上
  • 小规模纳税人减按1%如何填报申报表
  • 计提所得税会计处理
  • 专款专用需要缴纳企业所得税吗?
  • 印花税应计入什么账户
  • 电汇汇票和电汇的异同点
  • 股权转让开票怎么做账
  • 利润总额与毛利的区别
  • 未达起征点的税金如何做账
  • 冲减上年度收入的会计分录
  • 企业所得税年报错了怎么更正
  • 高新技术企业在增值税有什么优惠
  • 公司进项销项税差异较大
  • 开发票时税点开里怎么算?
  • 预缴税款是开票金额的多少
  • 免抵税额计入什么科目
  • 增值税专用发票可以开电子发票吗
  • 年底增值税有余额吗
  • 代购商品委托书怎么写
  • 委外加工企业怎么样降本
  • 进口税退税
  • 没进项发票要交多少税
  • 抵扣联复印件可以做账吗
  • 交强险保单被保险人写谁都行?
  • 海关增值税专用缴款书抵扣期限
  • 企业接受投资者的土地使用权投资
  • 斐讯路由器地址在哪里看
  • Windows10如何修复引导
  • saproxy.exe - saproxy是什么进程 有什么用
  • 常见转移支付事项有哪些情况
  • 工伤认定方法有几种方式呢
  • php 数组对象
  • _system~.ini 病毒
  • PHP:session_write_close()的用法_Session函数
  • 销项负数发票应该给谁
  • win11搜索栏不能用
  • php rewind
  • node.js如何安装
  • phpcrawl
  • php十进制转二进制算法
  • 如何计算公司需增加的营运资金
  • 数学建模python 怎么用
  • 社保主要有以下哪些方面
  • 工会会费收取
  • 设备折旧费怎么使用
  • 织梦系统
  • db2之间的数据库迁移
  • 什么人适合单干
  • 未计提完固定资产怎么办
  • 增值税纳税申报表附列资料(一)
  • 小规模以前年度城建税未计提
  • 合伙企业与公司相比,有什么优势呢?
  • 营业外支出贷方余额
  • 劳务公司开出发票没有收到钱,怎么做成本
  • 应收帐款 发票
  • sqlserver的分页语句
  • sqlserver获取当前年
  • sql server复制功能
  • 磁盘清理后文件还在吗?
  • vista改win7
  • win10怎么获取
  • windows自带的应用程序
  • Windows7更改用户名
  • 如何远程登录路由器
  • 给网页添加javascript
  • css清除浮动方法有哪几种
  • js在对象的方法中访问属性name的语法为
  • js中tolocalestring
  • python多线程怎么用
  • 广西税务12366如何查看代他人缴费发票
  • 广州契税补贴2022政策
  • 网络发票管理系统
  • 如何做好协税工作
  • 无锡市国税
  • 个人所得税减免标准及明细
  • 广州地税局官网办事点
  • 高速公路过路费电子发票在哪里开
  • 2020十大经济年度人物揭晓
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设