As the title says, how to file_get_contents() an URL which contains spaces?
Is urlencode() who doesn't work in this case, or it's my brain who doesn't work?
Is urlencode() who doesn't work in this case, or it's my brain who doesn't work?
<?php
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));
}
?>
Comment