ProdigyLV Posted February 12, 2020 Report Share Posted February 12, 2020 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? Quote Link to comment Share on other sites More sharing options...
briedis Posted February 12, 2020 Report Share Posted February 12, 2020 Uztaisi proof-of-concept šeit https://3v4l.org/ Parādi to kodu, kas nestrādā, ar ievaddatiem un izvaddatiem. Quote Link to comment Share on other sites More sharing options...
Grey_Wolf Posted February 12, 2020 Report Share Posted February 12, 2020 i.. burts priekšā funkcijai .. Quote Link to comment Share on other sites More sharing options...
Grey_Wolf Posted February 12, 2020 Report Share Posted February 12, 2020 aaa.. PHP. COM izrādās.. fuj... PHP.net.. Quote Link to comment Share on other sites More sharing options...
aaxc Posted February 17, 2020 Report Share Posted February 17, 2020 brieža norādītajā lapā notestējot vis strādā: Quote Link to comment Share on other sites More sharing options...
Grey_Wolf Posted February 19, 2020 Report Share Posted February 19, 2020 On 2/17/2020 at 1:37 PM, aaxc said: brieža norādītajā lapā notestējot vis strādā: str_ i replace !!!! es jau rakstīju burtiņš i bez strādā tikai ar tīriem latīņu simboliem, ja gribi UTF-8 tad i .. tas attiecās uz visām string funkcijām .. Quote Link to comment Share on other sites More sharing options...
aaxc Posted February 19, 2020 Report Share Posted February 19, 2020 @Grey_Wolf Quote Link to comment Share on other sites More sharing options...
Grey_Wolf Posted February 19, 2020 Report Share Posted February 19, 2020 Servera konfigurācija cita.. - bet ja neizmantosi i variāciju, tad būs serveri uz kuriem dabūsi laukā brīnumu lietas.. Quote Link to comment Share on other sites More sharing options...
Grey_Wolf Posted February 19, 2020 Report Share Posted February 19, 2020 https://www.php.net/manual/en/function.str-ireplace.php .. - manuālis, un velreiz manuālis.. Quote Link to comment Share on other sites More sharing options...
aaxc Posted February 19, 2020 Report Share Posted February 19, 2020 Nav nekāda sakara ar UTF8 Quote Link to comment Share on other sites More sharing options...
aaxc Posted February 19, 2020 Report Share Posted February 19, 2020 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 Official documentation: str_replace 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). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.