Jump to content
php.lv forumi

str_replace stādā bet ne vienmēr


ProdigyLV

Recommended Posts

Es vēlos tekstā aizvietot vārdus ar citiem vārdiem. Būtībā teksts ir kā templeits. Es simtiem reižu esmu izmantojis str_replace un vienmēr vis ir bijis ok. Tagad, kad vaig aizvietos "[vards]" str_replace nestrādā. str_replace("var1" 'ProdigyLV', $text); strādā, bet str_replace("[var1]" 'ProdigyLV', $text); un str_replace("{var1}" 'ProdigyLV', $text);  nestrādā. WTF!

Visur itkā UTF8.

Kādam kādas idejas?

Link to comment
Share on other sites

UTF-8 Safe Functionality

Special mentions for stuff which may be “surprisingly” safe with UTF-8. Note if “well formedness” is mentioned, it may mean you should be checking the strings for well formedness before using these functions.

explode

  • Official documentation: explode
  • Risk: none

So long as all arguments used are well formed UTF-8, no problems.

This works because every complete character sequence in a UTF-8 string is unique (cannot be mistaken as part of a longer sequence)

str_replace

So long as all arguments used are well formed UTF-8, no problems.

This works because every complete character sequence in a UTF-8 string is unique (cannot be mistaken as part of a longer sequence).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...