rhock_95 Posted November 26, 2007 Share Posted November 26, 2007 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 Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted November 26, 2007 Share Posted November 26, 2007 <?php $pattern="()-,"; $replacement=""; preg_replace($pattern,$replacement,$phone);?> Quote Link to comment Share on other sites More sharing options...
rhock_95 Posted November 26, 2007 Author Share Posted November 26, 2007 thanks for the quick response...getting this: Warning: Unknown modifier '-' on line 144 lines 143,144: $replacement=""; preg_replace($pattern,$replacement,$phone); Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted November 26, 2007 Share Posted November 26, 2007 changed to ereg_eplace for all instances <?php $pattern="()_,"; $replacement=""; ereg_replace($pattern,$replacement,$phone);?> Quote Link to comment Share on other sites More sharing options...
rhock_95 Posted November 26, 2007 Author Share Posted November 26, 2007 now getting this: Unknown modifier '\' Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted November 26, 2007 Share Posted November 26, 2007 changed to ereg_eplace for all instances <?php $pattern="()_,"; $replacement=""; ereg_replace($pattern,$replacement,$phone);?> Quote Link to comment Share on other sites More sharing options...
rhock_95 Posted November 26, 2007 Author Share Posted November 26, 2007 thanks for the time... not getting any errors but the numbers are still being displayed with the "(),-" characters...?? Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted November 26, 2007 Share Posted November 26, 2007 are the characters in the html on the page itself? if so it wont remove it. Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 26, 2007 Share Posted November 26, 2007 $str = '(xxx) xxxx-xxxx-xx'; $str = preg_replace('([\(\)\-\s])', '', $str); echo $str; edited i remove white spaces on the string... Quote Link to comment Share on other sites More sharing options...
rhock_95 Posted November 26, 2007 Author Share Posted November 26, 2007 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? Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 26, 2007 Share Posted November 26, 2007 sorry .. here $str = '(xxx) xxx-xxxx'; $str = preg_replace('([\(\)\-\s])', '', $str); echo $str; Quote Link to comment Share on other sites More sharing options...
rhock_95 Posted November 26, 2007 Author Share Posted November 26, 2007 some success with the following: (I commented out the first line) //$phone = '(foo) - o'; $phone = preg_replace('([\(|\)\-])', ' ', $phone); echo $phone; however the output is xxx xxx xxxx how can I get rid of the spaces? Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 26, 2007 Share Posted November 26, 2007 i guess this is solved your not reading my post try the second post i made............ sorry .. here $str = '(xxx) xxx-xxxx'; $str = preg_replace('([\(\)\-\s])', '', $str); echo $str; Quote Link to comment Share on other sites More sharing options...
rhock_95 Posted November 26, 2007 Author Share Posted November 26, 2007 I was only using "(xxx) xxx xxxx" to show the formatting of the data in the db the script sees the data as: $phone= ' <td>'.$data['phone'].' </td>'; Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 26, 2007 Share Posted November 26, 2007 $phone= ' <td>'. preg_replace('([\(\)\-\s])', '', $data['phone']).' </td>'; Quote Link to comment Share on other sites More sharing options...
rhock_95 Posted November 26, 2007 Author Share Posted November 26, 2007 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... Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 26, 2007 Share Posted November 26, 2007 that is bit longer to discuss but you might need ajax or simply a JavaScript to call the page and resize it accordingly.. Quote Link to comment Share on other sites More sharing options...
rhock_95 Posted November 26, 2007 Author Share Posted November 26, 2007 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... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.