Function 电话Href-Link-Regex

Function 电话Href-Link-Regex,function,hyperlink,Function,Hyperlink,使用此代码返回电话号码: <a href="tel:<?php $stel = get_field('fl_telephone');echo $stel; ?>"> 我需要将其转换为: +441234567890 i、 e.不带(0)和空格。我在javascript中找到了这个解决方案,但是如何在wordpress中为我的函数代码实现正则表达式呢 $('a[href^="tel:"]').attr('href', function(_,v){ return v

使用此代码返回电话号码:

<a href="tel:<?php $stel = get_field('fl_telephone');echo $stel; ?>">
我需要将其转换为:

+441234567890
i、 e.不带(0)和空格。我在javascript中找到了这个解决方案,但是如何在wordpress中为我的函数代码实现正则表达式呢

$('a[href^="tel:"]').attr('href', function(_,v){
    return v.replace(/\(0\)|\s+/g,'')
});

我相信你可以这样做:

$stel = '+44 (0) 1234 567 890';
$stel = preg_replace( '/\(0\)|\s+/', '', $stel );

有关更多详细信息,请查看函数。

我相信您可以这样做:

$stel = '+44 (0) 1234 567 890';
$stel = preg_replace( '/\(0\)|\s+/', '', $stel );

有关更多详细信息,请查看函数。

hmmm,简单的php问题应在stackoverflow上提问hmmm,简单的php问题应在stackoverflow上提问