Php 用特殊字符替换字符串
我有一个字符串:Php 用特殊字符替换字符串,php,replace,Php,Replace,我有一个字符串:image/fewe,我想用其他东西来替换它,但我不知道该怎么做,可能需要帮助吗 str_replace("replace_me", "replace_with", 'image/fewe'); preg_replace() // you'll need to look that up to match your regex with your needs. 不知道你还想找什么 $string = 'image/fewe'; $replaceItWith = 'another
image/fewe
,我想用其他东西来替换它,但我不知道该怎么做,可能需要帮助吗
str_replace("replace_me", "replace_with", 'image/fewe');
preg_replace() // you'll need to look that up to match your regex with your needs.
不知道你还想找什么
$string = 'image/fewe';
$replaceItWith = 'another string';
$result = str_replace('image/fewe', $replaceItWith, $string);
如果要搜索字符串中的模式,请使用
preg\u replace()
请澄清您确切拥有的字符串(例如,image/fewe
或image/fewe您没有太多细节,因此我建议您在这里查看:
@draevor在标题、标记和帮助内容中的位置。@draevor问题用php标记,问题标题也用php前缀:。因此,php。(我们必须假设)删除了不相关的信息…您的截止日期是否在周一并不重要。您应该提供相关信息,请参阅我的第一条评论。到目前为止,您的问题的有效答案也可以是$str='foo';
假设$str='image/fewe';
。它将字符串替换为其他字符串(在本例中为foo
)。谢谢,第一个(str_replace)有效:-)