位置: 编程技术 - 正文

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

  • 金税三期怎么合理避税
  • 企业出售土地的土地增值税计算方法
  • 公路客运企业应走集约化经营
  • 商誉 会计
  • 通货膨胀的含义及通货膨胀率的计算
  • 企业结算时待摊费用怎么办
  • 计提工资是包含社保吗
  • 投资性房地产收入计入什么科目
  • 金税盘减免政策依据
  • 增值税申报失败怎么撤销
  • 视同销售货物缴纳增值税的有哪些?
  • 小规模建筑公司预缴增值税
  • 材料税款抵扣
  • 17税点变更成16税点
  • 网上购物退款后又收到产品了怎么办
  • 增值税专用发票抵扣期限
  • 一般纳税人开3个点的票不能抵扣进项
  • 易票365怎么认证发票
  • 一般纳税人辅导期预缴
  • 小微企业差旅费可以税前扣除吗
  • 房地产企业预付账款为负数
  • 税务机关代码不能为空怎么解决
  • 一次发放数月的高温津贴如何计算个税?
  • 坏账准备为负数怎么填资产负债表
  • 微软正式宣布收购动视暴雪
  • 开成品油发票要注意什么?
  • 如何养成良好的安全行为
  • 处置子公司属于调整事项吗
  • 暂估营业收入会增加吗
  • 实物折扣例题
  • 实收资本和注册资本不一致的会计处理
  • vue2路由跳转页面不刷新问题
  • 存货需要计算填列吗
  • vue全家桶介绍
  • 减免税款月末怎么结转
  • 应交税金应交增值税科目设置
  • 待处理财产损溢增加是哪方
  • 银行存钱转账
  • 附加税费用
  • 发票开错对方已抵扣该怎么处理?
  • 营业外支出影响企业利润吗
  • mysql 随机抽样
  • 28栏分次预缴税额是手动填写吗?
  • 制造费用账户在月末一般没有余额
  • 买房的社保指的是什么
  • 运输费计入什么科目分录
  • 购进商品售价金额核算
  • 外埠存款主要使用范围
  • 支付宝收入什么意思
  • 职工体检可以从工会经费支出
  • 跨行收报属于什么科目
  • 电脑属于固定资产哪类
  • 购入固定资产入账会计处理
  • iis怎么打开项目
  • win7自带的多媒体播放程序是什么
  • DWHeartbeatMonitor.exe进程是什么意思 DWHeartbeatMonitor是安全的进程吗
  • windows7英雄联盟老是崩溃
  • 笔记本触摸屏无法使用了
  • linux抓包语句
  • win10预览版好吗
  • scrollWidth,clientWidth与offsetWidth的区别
  • android recycleview 刷新
  • css table-cell
  • Python+Wordpress制作小说站
  • html lang属性
  • jQuery的Ajax用户认证和注册技术实例教程(附demo源码)
  • jquery使用css
  • unity3d赛车游戏毕业设计
  • jquery示例
  • 信息页文内画中画广告js实现代码(文中加载广告方式)
  • jquery设置图片大小
  • 加油站怎么收税
  • 教师十三薪是什么意思
  • 税务局解决户口吗
  • 山东威海文登宋村镇有哪些村
  • 12366属于哪个部门
  • 怎样查询一个企业是不是一般纳税人
  • 岗位能手竞赛
  • 12366国税网上申报
  • 企业资金运转资金投放
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设