位置: 编程技术 - 正文

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

  • 缴纳所得税的账务处理
  • 处置固定资产增值税税率
  • 营业外支出增加的原因
  • 结售汇有金额限制吗
  • 生鲜配送公司财务制度
  • 支付宝过路费开票小程序
  • 事业单位私车公用条例
  • 票据贴现业务利润怎么算
  • 坏账冲回要纳税调减吗
  • 增值税普通电子发票可以抵税吗
  • 税收完税证明怎么打印
  • 事业单位库存物品
  • 国有资产如何保值
  • 搬迁到新租赁厂房的费用入什么科目?
  • 工程发票是不是都要异地预缴
  • 伙食支出设立的明细
  • 企业的耕地占用税怎么算
  • 教育费附加是用来干嘛的
  • 微信支付的钱到哪里去了
  • 劳务服务公司业务范围
  • 存货相关的会计科目
  • 外汇实收资本如何做账
  • 能抵扣税款的发票有哪些
  • 购入材料未入库
  • 专用发票超过360天作废
  • 货运发票与运输发票的区别
  • 合作社免税收入需要成本吗?
  • 收到总公司拨款发奖金如何入账
  • 红冲无票收入怎么报税
  • cpu天梯图2022最新排行榜
  • 现金流量表的计算公式原理
  • 普通发票的进项票怎么做分录
  • win10电脑声道怎么设置
  • thinkphp 5.0.24 rce
  • PHP:imagerectangle()的用法_GD库图像处理函数
  • phpwhile用法
  • 工业企业采购供应管理
  • php读取xml文件
  • 附加税多交了怎么办理退税
  • 特殊动产的一物数卖履行顺序
  • 计提营业税金及附加比例
  • 多交增值税可以做营业外支出吗
  • 个体户办营业执照网上怎么申请
  • 工资应纳税额怎么算
  • 代缴社保零申报对个人有影响吗
  • 房屋出租 交税
  • dedecms怎么更换模板
  • 改签费可以进项转出吗
  • 应交税费账户的用途和结构是怎样的
  • 管理费用结转到哪个科目
  • 暂估有几种处理方法
  • 事业单位发放生育津贴从哪年执行的
  • 调整以前年度的费用怎么做
  • 免征企业所得税的有哪些行业
  • 商业企业长期负债怎么办
  • 这么查看
  • 数据库备份sqlserver
  • linux系统关机重启命令
  • winserver是什么意思
  • win7系统升级到win10后,还能还原回来吗
  • windowsxpdos命令
  • linux系统查看磁盘io
  • 如何手动修复模糊图片
  • mysql删除key
  • Linux基本命令使用
  • win10周年版
  • linux如何使用双屏
  • python 安装setup
  • cocos2dx4.0入门
  • linux shell脚本教程
  • javascript基础笔记
  • CLASS_CONFUSION JS混淆 全源码
  • js中的继承
  • 使用权资产
  • 安置残疾人就业增值税即征即退优惠
  • 在地税局工作是什么编制
  • 银行收取个人贷款的费用
  • 河北省国家税务局电子税务局官网
  • e福州怎么帮家人登记
  • 争议问题
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设