pretty in Browser UGLY in source.
| From: | Lewis Bergman | Date: | Fri, 09 Jun 2000 12:44:44 +0000 |
| Subject: | pretty in Browser UGLY in source. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-1387@lists.php.net to get a copy of this message | ||
My problem is that I cannot seem to solve the problem of the UGLY html source
output by this code. The code looks great in the browser but if you view the
source you get this:
<A HREF="help.php#addresses
" target="right"><BR><FONT SIZE=+1>Addresses
</FONT></A><BR>
<A HREF="help.php#nick
" target="right">Nick Name
</A><BR>
<A HREF="help.php#email_add
" target="right">Email
</A><BR>
I would like it to output this instead:
<A HREF="help.php#addresses" target="right"><BR><FONT
SIZE=+1>Addresses</FONT></A><BR>
<A HREF="help.php#nick" target="right">Nick Name</A><BR>
<A HREF="help.php#email_add" target="right">Email</A><BR>
As if someone with some sense wrote the page. But it seems rthat no matter what
I try it doesn't work.
I tried collecting the vars at the end of the loop and then printing them out
but that didn't work eithert. Any ideas would be appreciated.
<?php
/**
** left_help.php
**
** This is the code for the left bar (frame). The left bar normally shows the
folders ** available, and has cookie information. This file is only used for
the help system. ** To be used, webmail must be called with ?help.php.
**
**/
/**
** Array used to list the include .hlp files, we could use a dir function
** to step through the directory and list its contents but it doesn't order those.
** This should probably go in config.php but it might mess up conf.pl
**/
$helpdir[0] = "basic.hlp";
$helpdir[1] = "main_folder.hlp";
$helpdir[2] = "read_mail.hlp";
$helpdir[3] = "addresses.hlp";
$helpdir[4] = "compose.hlp";
$helpdir[5] = "folders.hlp";
$helpdir[6] = "options.hlp";
$helpdir[7] = "FAQ.hlp";
/**
** Build a menu dynamically for the left frame from the HTML tagged right frame include (.hlp)
files listed in the $helpdir var.
** This is done by first listing all the .hlp files in the $helpdir array.
** Next, we loop through the array, for every value of $helpdir we loop through the file and look
for anchor tags (<A NAME=) and
** header tags (<H1> or <H3>).
**/
if (!file_exists("../help/$user_language")) // If the selected
language doesn't exist, use english
$user_language = "en";
while ( list( $key, $val ) = each( $helpdir ) ) { // loop through the array of files
$fcontents = file("../help/$user_language/$val"); // assign each line of
the above file to another array
while ( list( $line_num, $line ) = each( $fcontents ) ) { // loop through the second array
$temphed="";
$tempanc="";
if ( eregi("<A NAME=", $line, $tempanc)) { // if a name anchor is
found, make a link
$tempanc = $line;
$tempanc = str_replace("<A NAME=", "", $tempanc);
$tempanc = str_replace("></A>", "", $tempanc);
echo "<A HREF=\"help.php#$tempanc\" target=\"right\">";
}
if ( eregi("<H1>", $line, $temphed)) { // grab a
description for the link made above
$temphed = $line;
$temphed = str_replace("<H1>", "", $temphed);
$temphed = str_replace("</H1>", "", $temphed);
echo "<BR>";
echo "<FONT SIZE=+1>" . _("$temphed") .
"</FONT></A><BR>\n"; // make it bigger since it is a heading
type 1
}
if ( eregi("<H3>", $line, $temphed)) { // grab a
description for the link made above
$temphed = $line;
$temphed = str_replace("<H3>", "", $temphed);
$temphed = str_replace("</H3>", "", $temphed);
echo "" . _("$temphed") . "</A><BR>\n";
// keep same size since it is a normal entry
}
}
}
?>
Also I have heard that str_replace is faster than ereg_replace. Is this true?
--
-Lewis Bergman-
Texas Communications
915-695-6962
4309 Maple St.
Abilene, TX 79602