as the title says i have a string like this:
$string = "Hello World<br>hello world<br><br>";
now i want to get rid of the <br>
s at the end of this string so it looks like this:
$string = "Hello World<br>hello world";
I tried this:
preg_replace('/^(<br>)*/', "", $string);
but this did not work. maybe someone knows the right regex.
greetings peter
You're close, you used ^ at the start of the regexp, which means "match the start of the string." You want $ at the end, which means, "Match the end of the string."
preg_replace('/(<br>)+$/', '', $string);