Question

How to parse the Url which in the format as shown

http://localhost/CorrectCodeToDeploy/healthkatta/index.php?r=site%2FArticle%2F2013%2F07%2F13%2FDisadvantages-of-smoking-51e12690a5a58

Want to get rid of the special characters %2Fand put / instead . I have shared a link of an article to facebook
but when i access this link from facebook it comes in the format as mentioned above and the content is not properly accessed in Yii.How can i write the pattern to access this kind of url in yii

Was it helpful?

Solution

Maybe you can directly decode your $_GET in your index.php file, something like:

$_GET = array_map('urldecode', $_GET);

Please be aware the above doesn't work with nested arrays, so you need to create a more in depth recursive function like (not tested though) :

function urldecodeArray($strArr){
    if (!is_string($strArr) && !is_array($strArr)) {
       return $strArr;
    }
    if(is_string($strArr)) {
        return urldecode($strArr);
    }
    foreach ($strArr as $key=>$value) {
       $strArr[$key] = urldecodeArray($value);
    }
    return $strArr;
}
$_GET = urldecodeArray($_GET);

OTHER TIPS

You can just to use urldecode() function

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top