Current location: Hot Scripts Forums » Programming Languages » PHP » Need simple code for sensor/block numbers


Need simple code for sensor/block numbers

Reply
  #1 (permalink)  
Old 12-29-11, 06:31 AM
PHP Warner PHP Warner is offline
Newbie Coder
 
Join Date: Mar 2006
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Question Need simple code for sensor/block numbers

Hello friends,

I need simple function for block numbers on variable. For example my variable:

$message="Hi, everybody this is testing number blocking 0590 394 32 25";

I want to show * for all numbers and string should be:

Hi, everybody this is testing number blocking *** *** ** **

Thank you very much for advice.
Reply With Quote
  #2 (permalink)  
Old 12-29-11, 06:36 AM
PHP Warner PHP Warner is offline
Newbie Coder
 
Join Date: Mar 2006
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
I write something for explain my request.

$numbers = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0");
$message = "Hi, everybody this is testing number blocking 0590 394 32 25";
echo str_replace($numbers, "", $message);

It should be works but I need more clean function with preg_replace.

Thank you.
Reply With Quote
  #3 (permalink)  
Old 12-29-11, 07:27 AM
alxkls alxkls is offline
Newbie Coder
 
Join Date: Nov 2011
Posts: 98
Thanks: 0
Thanked 9 Times in 9 Posts
well you could do what you jusr said except
str_replace($numbers, "*", $message);

or if you want to use a regular expression(and that is the exact format that will be shown) it should look like
Code:
/(\d+)( )(\d+)( )(\d+)( )(\d+)/is
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
OTO Redirect Code Placement Tony S. HTML/XHTML/XML 7 07-25-09 09:31 AM
Perl LWP loses html code?! jialanw Perl 22 04-13-09 02:14 PM
Need captcha for html+php contact form sujata_ghosh PHP 6 03-22-09 03:46 PM
Looking for simple "Password" script to access a hidden page. Nigel DV Script Requests 16 04-12-05 07:39 PM
Need a simple user code! dave111 Script Requests 1 09-07-03 09:48 AM


All times are GMT -5. The time now is 08:59 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.