位置: 编程技术 - 正文

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

  • 企业所得税季度预缴纳税申报表
  • 防火门属于固定式防火风格
  • 转正后个税增加
  • 发票弄丢下一步怎么办
  • 汇算清缴a107020表
  • 金税盘查发票明细
  • 居民企业核定征收企业所得税的情形有哪些
  • 转让土地使用权属于销售无形资产吗
  • 行政事业单位应当进行摊销的无形资产
  • 金税三期中个税怎么算
  • 母公司代子公司付款合法吗
  • 委托收款被拒绝后要怎么做
  • 个人增值税业务有哪些?
  • 建筑业商业保险受益人可以是公司吗
  • 账本印花税怎么缴纳
  • 小规模纳税人免税怎么做账
  • 子公司注销投资收益是否纳税合并层面
  • 个人营业执照如何办理社保
  • 小规模税率还是1%吗
  • 从贸易公司购买来的货物可以退税吗
  • 食堂购买蔬菜计算公式
  • 结转法定盈余公积会计分录怎么写
  • 工程施工科目月末如何结转
  • 任务管理器网络占用率100%怎么办
  • swoole和websocket的区别
  • 仓储费计入存货成本吗
  • wordpress登录注册
  • 员工不愿意缴纳个税 需要公司承担吗
  • php new
  • php获取表单数据的方法和区别
  • php深度分析
  • 库存股属于什么
  • 如何根据科目余额表编制财务报表
  • 前端开发从入门到放弃
  • 推荐 4个有趣实践作业
  • es6对象扩展运算符
  • input输入框限制最大字数
  • 代销手续费的税率
  • 驱动开发做得长久吗
  • 咨询服务业的收入确认原则
  • 分公司发生的业务,开票给总公司
  • mysql日志文件在哪里
  • 织梦cms要钱吗
  • 预提工资的会计处理
  • 工会经费发放奖励个税处理
  • 一般纳税人可以转小规模纳税人吗
  • 汽车加油增值税专用发票
  • 一般计税预缴增值税2%怎么算
  • 补缴以前年度的印花税会计分录
  • 金税四期上线企业还活吗
  • 损益类科目都是当期损益吗
  • 减免所得税额是自动计算吗
  • 税务师有用么,相当于中级还是高级
  • 合伙企业怎么建账
  • 收到供应商上年的发票
  • 固定资产计提完折旧残值怎么处理
  • 免抵退 免退
  • 公司员工出差住酒店费用明细有问题怎么办
  • 发生以下情况
  • 员工借支备用金属于现金流量的哪类
  • win10系统预览版
  • win7系统怎么更新到win10
  • ubuntu debian
  • jsp环境变量配置的步骤
  • 双系统卸载deepin
  • windows7凭据管理器
  • linux文件中添加内容
  • win8登录密码修改
  • js抓取网页内容
  • css一个页面跳转到另一页面
  • 移动端一般用什么布局
  • python模块导入的几种方法
  • Unity3D AsssetBundle加载效率比较
  • javascript val
  • CentOS下mysql定时备份Shell脚本分享
  • android 获取时区
  • 土地重置成本价
  • 拟录用人员公示后还会递补吗
  • 河北电子税务局电话
  • 河北省税务局地址邮编
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设