I'm trying to take a text from a file and insert it in an html page... My text would have html tag in it. But if I don't use htmlEntities it would be possible except if in the text I start with 1<2 and later in the text I use 6>4 then all the the text would dissapear cause html would think it's a tag and if I use htmlEntities to write the apropriate code < or > than I won't be able to execute any html tag ...is there a function that scan a string and let html tag and convert other specialchar ???
thanks
If you know the exact strings that you are trying to keep, try using the preg_replace function. You can substitute certain defined sections of your code with the appropriate code.
my problem is that I never know what is in the textfile. The user can access the text file and add some text or delete some and I never know what tag he will use
Well, if you code to standards, all your tags should end in "> or /> because you used quotes around them. if That were the case, you could distinguish between user inputed values and actual HTML tags.