0

I want to colorize the keywords of my Text-Output. I am pulling the keywords out of the DB. Running a loop and using this function to change the code:

str_ireplace($row['keyword'], "<span class=\"".$row['mycolor']."\">".$row['keyword']."</span>", $_POST['mytext'])

My localhost is working fine. The result is for example this:

more text... <span class="red">my keyword</span> more text...

The exact same file with the exact same "keyword"-DB is producing this in the www:

more text... <span class="red<br ></span>">my keyword</span> more text...

I dont understand why the webserver is adding the <br ></span> on the wrong position.

Do you have any clues?

I updated the keywords-CSV file (utf-8) before and uploaded it to the DB. I am doin gthis the last two years. But now there is the strange <br >.

Ben
  • 73
  • 7
  • if you came from windows and are now on Linux try using dos2unix (to convert line endings) https://linux.die.net/man/1/dos2unix – Cameron Jul 19 '21 at 19:08
  • Hi, I am not converting a TextFIle. I am changing html code via str_ireplace which I got out of my DB. – Ben Jul 19 '21 at 19:11
  • and when you look at the row in the db there is no
    or did it upload with a
    ?
    – Cameron Jul 19 '21 at 19:17
  • There is no
    . I am using a xls file fo rall my keywords. After that I converting the file into a csv file (utf-8) and uploading it into my DB. There are no
    at all. In the past this procedure worked fine.
    – Ben Jul 19 '21 at 19:19
  • maybe this will help, looks like maybe a function is converting /r/n into
    somewhere in your flow https://stackoverflow.com/questions/39514698/str-ireplace-or-preg-replace-replaced-break-tag-into-r-n
    – Cameron Jul 19 '21 at 19:23
  • But it is all working on my localhost. Thats the strange thing. – Ben Jul 22 '21 at 05:48

0 Answers0