[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-general
Subject:    [PHP3] Escaping Special Characters in Text File
From:       musaluke Anthony <musaluka () nm ! com ! zm>
Date:       1999-12-16 5:59:39
[Download RAW message or body]

Hi all,
I have ascript, see below, that reads a text file into a web page.
Unfortunately, if the text file contains double or single quotes or such
special characters, they are prefixed with a backslash by the script.
How do I tell the script not to place a back slash before these
characters?

Sample output from the story:
------------------------------------------------------------------
  \"We have to prepare adequately for such game\'s.\" Mr Mvula said. \"
For a team like that to qualify for this competition then
  they must have worked hard for it.\"
------------------------------------------------------------------

Here is the script:
------------------------------------------------------------------
<?
    include "header.php3";
 ?>

<table border="0" cellspacing="0" cellpadding="0" width="95%" >

 <?
  $file_name = "stories/opinion.txt";     //normal text file to read
   $lines = file($file_name);
   $cnt = count($lines);
  for ($i=0; $i<$cnt; $i++)
  {
    echo "<TR ><TD>\n";
    if ($i == 0)
       {
          echo "<b><font color=\"#000000 size=\"+4 face=\"verdana,
arial, sans-serif\">$lines[$i]</font></b><BR>\n";
       }
    elseif ($i == 2)
       {
          echo "<b><font color=\"#000080 size=\"2 face=\"verdana, arial,
sans-serif\">$lines[$i]</font></b>";
       }
     else
       {
          echo "<font size=\"2 face=\"verdana, arial,
sans-serif\">$lines[$i]</font><br>\n";
       }
     echo "</td></tr>\n";

   }
 ?>
</table>

<?
     include "footer.php3";
 ?>
----------------------------------------------------------------------------

Thanks a lot

Anthony


-- 
PHP 3 Mailing List <http://www.php.net/>
To unsubscribe, send an empty message to php3-unsubscribe@lists.php.net
To subscribe to the digest, e-mail: php3-digest-subscribe@lists.php.net
To search the mailing list archive, go to: http://www.php.net/mailsearch.php3
To contact the list administrators, e-mail: php-list-admin@lists.php.net

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic