Jump to content

[SOLVED] remove characters from string


rhock_95

Recommended Posts

hope this is a simple problem...

 

I have a couple of different scripts that display results from mysql DB queries and they work great on the regular web...but I am offering the same content for mobile browsers...specifically cell phones....So I am having to edit the (regular web) applications down to work on the micro browsers...

 

I am having good success with the scripts but I need some help with some fine tuning...I am currently hung up on two related problems...

 

1.) I need to strip some characters from a particular column result "(xxx) xxx-xxxx" to xxxxxxxxxx

 

2.) "(xxx) xxx-xxxx" being a telephone number...I need to hyperlink it so the phone will dial the number when selected...here is the second part of the problem.

 

Either of the following work on one script ...although the number still needs to be stripped of the (,),-

 

echo "<td><a href=\"wtai:$phone\">$phone</a></td>\n";
echo "<td><a href=\"tel:$phone\">$phone</a></td>\n";

 

however the other script using the following displays the numbers but they are not hyperlinked???

echo "<td><a href=\"wati:$phone\">$phone</a></td>\n";

 

first things first...how can I format the numbers ($phone)from (xxx) xxx-xxxx to xxxxxxxxxx as $phone ?

 

any ideas why either of the first examples work on one script for hyperlinking the numbers but not the second script?

 

TIA

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/78864-solved-remove-characters-from-string/
Share on other sites

all the html is generated by the php

 

.............................................................

 

$str = '(foo)  - o';

$str = preg_replace('([\(|\)\-])', ' ', $str);

echo $str;

 

sorry but I don't have a clue how to use this...can you show me using the variables from the code I have posted?

Thanks for all the replies and all your time

 

It works great and I learned some useful php...

 

thanks again...

 

BTW, the second part of the problem worked itself out in the mean time...the numbers display as a link and if viewed on a cell phone it will dial the number or as it to the contact list etc...

I am testing on two different smartphone emulators, a small screen cell phone and a PDA and so far I have not had any problem with the displays...php works very will with wireless protocol and like a charm on the newer phones...

 

...all the pages are stripped down to just content to keep the bandwidth to a minimum...most services charge per / KB rather than by the minute...

 

Thanks again...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.