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!

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' />

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

<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

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 2 guests