Forum Moderators: coopster
preg_match( '/^\+\+\+ (.*)/',$file,$pagetitle);
$pagetitle = preg_replace("/<[^>]+>/","",$pagetitle);
[b]$pagetitle = rtrim($pagetitle);[/b]
echo "<title>".$pagetitle[1]."</title>\n"; So the text file contains a line starting the "+++ " that I want to use for the page title. The line may contain HTML such as
<br> or <b> which I remove, then I want to remove the carriage return (and any other cruft) at the end otherwise </title> falls on a new line. Am I simply misunderstanding
rtrim?
[bugs.php.net...]
$pagetitle = str_replace("\n","",$pagetitle); does nothing at all. Also, strip_tags (which I tried before using preg_replace in the above example) returned the "r" result as with the rtrim. It's very strange as it should just work, I'm definitely missing something in the equation... The text files were created either in Linux or Mac OSX, nothing has ever been near Windows (if that makes a difference due to the differences wiith carriage returns).
preg_match( '/^\+\+\+ (.*)/',$file,$pagetitle);
$pagetitle = preg_replace("/<[^>]+>/","",$pagetitle[1]);
$pagetitle = rtrim($pagetitle[1]);
echo "<title>".$pagetitle."</title>\n";
P.S. I found internet in NC ;)
$pagetitle = rtrim($pagetitle);