FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


(close) PHP-Remove chars from string except numerical values





Flakky
Hi,

I need to filter a string so that all chars which aren't numerical are removed. For example:

$string='abc123/\[]';
would result in
$string='123';

I couldn't find it and I hope any of you can help Smile
Thanks in advance.

EDIT: Could someone close this, it has been solved.
Peterssidan
Code:
preg_replace('/[^0-9]/','',$string)
Star Wars Fanatic
Can't forget the $string =...

So, taking Peters code:

Code:
$numbers = preg_replace('/[^0-9]/','',$string)


Otherwise, that should work...
Flakky
Thanks, it worked perfectly! This can be closed Very Happy
Related topics
Importing an existing database...
Inserting data to MYSQL with a PHP script
Science - Anybody Interested
Zone Alarm Popup constantly
A very good PHP MySQL Tutorial
PhpNuke Installation Tutorial
Can I have some help with scripts for postmysite.frih.net
php..free account help
Javascript and Dynamic Select Boxes
PHP Remove Text?
PHP: fopen('./directory/$variable'); Problem
UTF-8 from MySQL to PHP
search, a bit contextual in php
preg_match
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.