note 78029 deleted from function.strstr by thiago
| From: | thiago@php.net | Date: | Tue, 28 Oct 2008 13:42:54 +0000 |
| Subject: | note 78029 deleted from function.strstr by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-145865@lists.php.net to get a copy of this message | ||
Note Submitter: fire.minded.design at gmail dot com
----
for eamon:
preg_replace is wonderful for that sort of thing, amongst so much else.
<?php
$string = "a string with!0o|u7t stuf34-f2~ in#4 in it";
// No numbers
$string = preg_replace("![0-9]!", "", $string);
// $string is now "a string with!o|ut stuf-f~ in# in it"
// Nothing but alphabetic
$string = preg_replace("![^0-9A-Za-z\s]!", "", $string);
// $string is now "a string without stuff in in it"
?>