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
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?

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.