如何使用PHP从字符串中删除特殊字符后的单词

I need one help.I need to remove some value from string using PHP. I am explaining my code below.

$data=['abcgh \\200ub','ascdvb\ 15.02','fgtrmky']

Here i need to remove the word 200ub with slash only where it will present not from all string.Please help me.

Using for loop to find first the string, then change it by replacing str_replace

$data=['abcgh \\200ub','ascdvb\ 15.02','fgtrmky'];
for($i=0;$i< count($data); $i++)
{
 if(strrpos($data[$i], "200ub"))
 {
   $data[$i] = str_replace("\\200ub","", $data[$i]);
 }
}

print_r($data);

Make a foreach to loop through every index in your array. Then replace your string with "" (nothing).

$data=['abcgh \\200ub','ascdvb\ 15.02','fgtrmky'];

$i = 0;
foreach($data as $string) {
    $data[$i++] = str_replace("\\200ub","", $string);
}

Or to remove both backslashes with it:

$data[$i++] = str_replace("\\\\200ub","", $string);

Try this

 <?php 
$data=['abcgh \\200ub','ascdvb\ 15.02','fgtrmky'];
for($i=0;$i<count($data);$i++){
    /*Here we are looping through array and check whether 200ub is present or not*/
    $result = stripos($data[$i],"200ub");
    /*If data is present we will replace that string with blank one*/
    if($result!=""){
        $data[$i]=str_replace("\\200ub","",$data[$i]);
    }
}
print_r($data);

?>