RE: [PHP] Strip Numbers

This is a discussion on RE: [PHP] Strip Numbers within the PHP General forums, part of the PHP Programming Forums category; You could use two substr()s or an ereg_replace() $result = substr($str, 0, 2) . substr($str, 5); or $result = ereg_replace(&...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-30-2003
Martin Towell
 
Posts: n/a
Default RE: [PHP] Strip Numbers

You could use two substr()s or an ereg_replace()

$result = substr($str, 0, 2) . substr($str, 5);
or
$result = ereg_replace("([0-9][0-9])990([0-9][0-9])", "\\1\\2",
$str);

Both are not tested, but should work

Martin


-----Original Message-----
From: Joe Harman [mailto:joe@harmanmedia.com]
Sent: Wednesday, 30 July 2003 4:52 PM
To: php-general@lists.php.net
Subject: [php] Strip Numbers


Hey could someone help me out here....

I need to strip numbers from a passed variable

ex. 3899007

all the numbers will have 990 (so that is the 4th, 5th & sixth
numbers... from the right...) I want to keep everything to the left of
the two 9s... is there an easy way to do that????

Joe Harman

http://www.HarmanMedia.com

This `telephone' has too many shortcomings to be seriously considered as
a means of communication. The device is inherently of no value to us. -
Western Union internal memo, 1876

__________ Information from NOD32 1.468 (20030725) __________

This message was checked by NOD32 for Exchange e-mail monitor.
http://www.nod32.com



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:46 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0