Hey DaniWeb community;
I am trying to create a web page that pulls its settings from a file called settings.xml, and apply them to the web page. The title is the tag I want to change now, but my code is not working. Here is the code:
<?php
//Open and store settings data into array
$settings = "settings.xml";
$setHandle = fopen($settings, 'r');
$lineCount = count(file($settings));
$i = 0;
while (!feof($setHandle)) {
$line = fgets($setHandle, 4096);
if(strpos($line,"<indexTitle>")) { //Look for indexTitle tag
$indexTitle = $line; //Set indexTitle as the current line
$indexTitle = str_replace("<indexTitle>", "", $indexTitle); //Strip both indexTitle tags
$indexTitle = str_replace("</indexTitle>", "", $indexTitle);
}
}
fclose($setHandle);
$i = 0;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $indexTitle ?></title> <!-- Set $indexTitle as the title for the page -->
</head>
<body>
Nothing here yet...
</body>
</html>
and settings.xml...
<note>Settings file for the online PHP editor</note>
<indexTitle>Change the title to this!</indexTitle>
<stuffer>Im here to take space</stuffer>
Thanks for your help!