简单的PHP字符串替换? [英] Simple PHP string replace?

查看:89
本文介绍了简单的PHP字符串替换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有此代码:

$abc = ' Hello "Guys" , Goodmorning';

我想用$^替换每次出现的"(双引号),以便字符串变为

I want to replace every occurrence of " (double quotes) by $^ so that string becomes

'Hello $^Guys$^ , Goodmorning'

我是PHP的新手;在Java中,我们可以很容易地通过调用字符串类replaceAll函数来做到这一点,但是如何在PHP中做到这一点呢?不使用正则表达式,我无法在Google上找到简单的方法.

I am new to PHP; in Java we can do this very easily by calling the string class replaceAll function, but how do I do it in PHP? I can't find the easy way on Google without using regular expressions.

使用或不使用正则表达式的语法是什么?

What is some syntax with or without the use of regular expressions?

推荐答案

看看 str_replace

$abc = ' Hello "Guys" , Goodmorning';
$abc = str_replace('"', '$^', $abc);

这篇关于简单的PHP字符串替换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆