Answer the question
In order to leave comments, you need to log in
Is it possible to add cyrillic encoding to rawurlcencode exceptions?
Good evening!
I need php to encode a string into url format like rawurlcencode does, but it doesn't encode cyrillic. Is there such a function?
Well, or if you create your own function to replace non-alphanumeric characters, then how can you specify the% 22 character (quotes) there?
function myUrlEncode($string) {
$entities = array('%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%2B', '%24', '%2C', '%2F', '%3F', '%25', '%23', '%5B', '%5D');
$replacements = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "+", "$", ",", "/", "?", "%", "#", "[", "]");
return str_replace($entities, $replacements, urlencode($string));
}
Answer the question
In order to leave comments, you need to log in
const players_online = '{"response":{"player_count":1080,"result":1}}';
const user = JSON.parse(players_online);
console.log(user.response.player_count);
Or \0x22, also a perfectly kosher way of representing double quotes in the $replacements array.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question