开发者

How to strip from a string those which are not in the a-z and 0-9 range?

I know a version of this but i'm looking for the simplest开发者_开发百科 way?

$string = "HeLLo$ my222 name is zolee0802343134";
$string = strtolower($string);
$replacement  = range (a, z);
$replacement2 = range (0, 9);

//
What comes here?
// 

I want to get this ->
$string = "hello my name is zolee";


Use regex for simplicity.

$string = "HeLLo$ my222 name is zolee0802343134";
echo preg_replace("/[^a-z ]/i", "", $string);

http://codepad.org/eDmXrnYR


Here you go: http://codepad.org/3KuCG2yf

<?php

$string = "HeLLo$ my222 name is zolee0802343134";
echo preg_replace("/[^a-zA-Z ]/", "", $string);

?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜