I have the following string
"This is very nice. Thanks for your support."
Now I want to remove the line that contains Thanks word
I have the following string
"This is very nice. Thanks for your support."
Now I want to remove the line that contains Thanks word
you need to explode the paragraph by fullstop. lets say your full paragraph is store in $str
$lines_arr = explode(".",$str);
now $lines_arr is an array contains numbers of lines.
now under loop you can check which lines contains "thanks" , if it is then skip it.
$string = '';
for($i=0; $i<(count($lines_arr)-1); $i++){
//with the help of strpos
if(strpos($lines_arr[$i],"Thanks") == false){
$string .= $lines_arr[$i].". ";
}
}
you can use str_replace
echo str_replace("Thanks", "", "This is very nice. Thanks for your support.");
# Output: This is very nice. for your support.