【发布时间】:2016-01-22 02:09:37
【问题描述】:
我尝试组合strtolower 和preg_replace,但我不知道如何嵌套它。我试过这样:
$res = strtolower(preg_replace("/[^a-zA-Z]/", "", $string));
我找到了this solution,但无法让它工作。我想要一个没有特殊字符的小写字符串:
我是一些特殊内容
变成
iamsomespecialcontent
我怎样才能做到这一点并将其存储在$res中?
【问题讨论】:
-
为什么这不起作用?
-
无论哪个函数嵌套最深,都会先出现。在这种情况下,就像您现在的代码一样,
preg_replace首先发生,然后preg_replace的输出被转换为更低,并输出到$res。 -
我不知道为什么上面的代码不起作用,但我用两行解决了它:
$string = strtolower(get_sub_field('a-pikto')); $res = preg_replace("/[^a-zA-Z]/", "", $string);...
标签: php