如何从字符串中删除单词?

时间:2011-05-05 15:16:54

标签: php arrays multidimensional-array

$arr =array("Raven Lexy","rajesh123","xw2z","lolaurita","Artin");
$arrfind= Array
(
    [0] => Ohh... Perfect! You got lucky lolaurita 
    [1] => I just logged in... didn't have to make a new profile same one is stilol here whoot whoot! lolArtin 
    [2] => Hey babe, so what do you think? Have you come across any bugs? We 40 pages of bugs we are fixing which should be done in a couple of weeks, than the real marketing starts :)  
);

我必须将上面的$ arr与$ arrfind的每个索引相匹配,并返回剩余的字符串将得到这样的结果。

$arrfind [0]=>Ohh... Perfect! You got lucky 
[1]=>I just logged in... didn't have to make a new profile same one is stilol here whoot whoot! lol
[2]=>Hey babe, so what do you think? Have you come across any bugs? We 40 pages of bugs we are fixing which should be done in a couple of weeks, than the real marketing starts :)

我该怎么办? 请帮忙, 感谢

2 个答案:

答案 0 :(得分:3)

使用str_replace,它接受​​数组作为参数。在你的情况下:

str_replace( $arr, "", $arrFind );

答案 1 :(得分:0)

<?php
$result = str_replace($arr, '', $arrfind);
?>