www.webdeveloper.com
Results 1 to 3 of 3

Thread: Changing é into html entities without touching the html elements ?

  1. #1
    Join Date
    Feb 2006
    Posts
    352

    Post Changing é into html entities without touching the html elements ?

    Good day to you all,
    I'm working on a script which take the text from a txt file and add his content to an php page.
    I have no problem with that part, see code below :

    PHP Code:

    $textsec 
    file_get_contents('text.txt');
    echo 
    nl2br($textsec); 

    This page can include <b> <u>... html element.

    Where my problem start is that it's possible that I get some :
    PHP Code:
    &eacute;
    &
    agrave;

    ..
    words with accent.. 
    How can I convert them to their respective html entitie code without touching my html element ?

    Thanks!

  2. #2
    Join Date
    May 2006
    Location
    the netherlands
    Posts
    454
    You could do something like this (untested)

    PHP Code:
    $str_entities htmlentities($str);
    $str_html preg_replace("/(&lt;)(.*)(&gt;)/U""<\\2>"$str_entities); 

  3. #3
    Join Date
    Sep 2008
    Location
    Mexico
    Posts
    786
    for what it seems that you are trying to do, readfile() might be the best option
    PHP Code:
    <?php
    echo readfile("text.txt");
    ?>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles