ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

[PHP] str_replace - is this even possible?

<< < (2/3) > >>

RedPillow:
Since I got your attention already, I'll ask if anyone knows, if it is possible in anyway for random <|p> and <|/p> -tags to get insterted into my code.
ALSO, str_replace wont find em either.

This is the output, don't mind about the contents  :-[



--- Code: Text ---<p>[18.26.23] - Rotation was <font color = 'orange'><b>225</b></font> degrees, done by <b>127.0.0.1</b>, who says: '<b>HIGHWAY|||</p><p>|||-CHESS BOARD|||</p><p>|||</b>'

I've highlighted the tags with '|||'s, which cause problem and I assure you, that I've gone trought EVERY FILE RELATED trying to find where those tags pop-up.
I've tried using find in text-editor, I've tried to strip and trim them and no I don't know what to do anymore...

This is just my foolish theory but ... might it be possible, since 'HIGHWAY' and 'CHESSBOARD' are obtained from text-file,
that they somehow contain invisible tags or something after them? Like HIGHWAY<|/p><|p> ?

Veign:
No such thing as invisible tags in a text file.  Your code has to be adding them or the text files have to already contain them.  Text files have 0 knowledge of HTML.

RedPillow:
Still weird tho ... I can print ie. CHESSBOARD as much as I want and it always puts <|/p><|p> after the word.  :huh:

Veign:
If you're taking raw text from a text file, processing it and spitting out some cleaned/washed version then your code is adding it or it exists in plain site.  No other options.

JoTo:
Hi Veign,

i was thinking about the array functionality of str_replace as well before i posted my solution of course. Problem is, that the replacements contain characters that will be replaced again (are in the search array).

E.g. if an "E" gets replaced with "012" and a "1" with "345" you end up with "03452" when using this approach. I've tested it first before i came back to my posted solution. As the characters in his string are random, you cant find an order of the search array that prevents this "reentrance".

Seems str_replace is not made for that you replace sth. with sth. that is in the search array. So this approach is not more effective but just won't work at all. :) Therefore this workaround.

For the other point i must agree with Veign. No black magic or voodoo here. Either the tags are in your source text already or your code adds them.

Greetings
JoTo

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version