PHP preg_replace 将 $ 转换为字母 S

标签 php seo preg-replace

我目前有一个非常棒的 preg_replace 系统可以满足我的 seo 需求,但我在使用一个字符时遇到了问题,那就是 $.我的代码将 $ 返回为空白,但我希望它能将 $ 变成字母 S。这可能只是一个小调整,但我确定如何将它挑出来。

    $urlname = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $info['name']);
    $urlname = strtolower(trim($urlname, '-'));
    $urlname = preg_replace("/[\/_|+ -]+/", '-', $urlname);  
    $seourl = strtolower($urlname);

最佳答案

你可以使用,strtr

echo strtr('Hello. I have $ Please replace the $', '$', 'S');

查看演示 Here

关于PHP preg_replace 将 $ 转换为字母 S,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33341537/

相关文章:

PHP JAXB 等价物

php - Zend Framework 1 更新操作

Php - Laravel 与 MAMP

php - alexa工具栏可以观看弹出窗口吗?

seo - 新的 404 未找到索引页面将如何影响排名?

php - Preg_replace 到 Preg_replace All

php - 正则表达式 - preg_replace 字符串

php - 当字符串包含数字时 Preg_replace 不起作用

php - php 中的 Curl-request > 带参数的 URL?

symfony1 - 为什么 meta 描述在 view.yml 中被填满了却还是空的?