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 Link to comment https://forums.phpfreaks.com/topic/78864-solved-remove-characters-from-string/ 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);?> Link to comment https://forums.phpfreaks.com/topic/78864-solved-remove-characters-from-string/#findComment-399124 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); Link to comment https://forums.phpfreaks.com/topic/78864-solved-remove-characters-from-string/#findComment-399127 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);?> Link to comment https://forums.phpfreaks.com/topic/78864-solved-remove-characters-from-string/#findComment-399131 Share on other sites More sharing options...
rhock_95 Posted November 26, 2007 Author Share Posted November 26, 2007 now getting this: Unknown modifier '\' Link to comment https://forums.phpfreaks.com/topic/78864-solved-remove-characters-from-string/#findComment-399138 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);?> Link to comment https://forums.phpfreaks.com/topic/78864-solved-remove-characters-from-string/#findComment-399139 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...?? Link to comment https://forums.phpfreaks.com/topic/78864-solved-remove-characters-from-string/#findComment-399143 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. Link to comment https://forums.phpfreaks.com/topic/78864-solved-remove-characters-from-string/#findComment-399146 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... Link to comment https://forums.phpfreaks.com/topic/78864-solved-remove-characters-from-string/#findComment-399147 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? Link to comment https://forums.phpfreaks.com/topic/78864-solved-remove-characters-from-string/#findComment-399150 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; Link to comment https://forums.phpfreaks.com/topic/78864-solved-remove-characters-from-string/#findComment-399151 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? Link to comment https://forums.phpfreaks.com/topic/78864-solved-remove-characters-from-string/#findComment-399156 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; Link to comment https://forums.phpfreaks.com/topic/78864-solved-remove-characters-from-string/#findComment-399158 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>'; Link to comment https://forums.phpfreaks.com/topic/78864-solved-remove-characters-from-string/#findComment-399163 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>'; Link to comment https://forums.phpfreaks.com/topic/78864-solved-remove-characters-from-string/#findComment-399165 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... Link to comment https://forums.phpfreaks.com/topic/78864-solved-remove-characters-from-string/#findComment-399207 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.. Link to comment https://forums.phpfreaks.com/topic/78864-solved-remove-characters-from-string/#findComment-399212 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... Link to comment https://forums.phpfreaks.com/topic/78864-solved-remove-characters-from-string/#findComment-399221 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.