Forum for discussing general topics related to Couch.
3 posts Page 1 of 1
Hello, I'm just wondering if there is a easy way to delete unwanted signs out of an input text. For example I have a phone number imput: +43 650 - 6897 - 15
and I want to use this input for a link like this: <a href="tel:+43650689715">+43 650 - 6897 - 15</a>
I would need the number without the empty spaces and "-". Is there a hidden option like excerpt, but for unwanted signs?

thank you!
Hi,

Just a bit of PHP should do it.
Please try the following (it assumes your input is a variable named 'tel' and outputs its stripped version in another variable named 'tel_ex') -
Code: Select all
<cms:set tel='+43 650 - 6897 - 15' />

<cms:php>
    global $CTX;
   
    $replace = array('-', ' '); // the characters to remove
    $str = str_replace( $replace, "", "<cms:show tel />" );
   
    $CTX->set( 'tel_ex', $str );
</cms:php>

<a href="tel:<cms:show tel_ex />"><cms:show tel /></a>

Output -
Code: Select all
<a href="tel:+43650689715">+43 650 - 6897 - 15</a>

Hope it helps.
Oh yess, this helped!

Thank you very much!!!
3 posts Page 1 of 1