- var_dump: documentation ( source)
- preg_replace: documentation ( source)
- header: documentation ( source)
<?php
$string = "Hello world<br> <br> ";
$input = preg_replace('/(<br>| | )*$/', '', $string);
header('Content-Type: text/plain');
var_dump($input);