mercredi 23 novembre 2016

How to design codes to parse urlencoded data to array?

I have made some codes to parse url encoded data to array.

What I did is something like below.

var_dump(getArrayFromUrlEncoded());

public function getArrayFromUrlEncoded(){

    $urlEncoded = "timestamp=2016-10-10%20&id=123%20";

    $urlDecoded = $this->decodeUrlEncoded($urlEncoded);

    $array = $this->makeUrlToArray($urlDecodded);

}

public function decodeUrlEncoded($urlEncoded){
    //some codes here
    return $urldecoded;
}

public function makeUrlToArray($urlDecoded){
    //some codes here
    return $arrays;
}

But When I made these codes, I feel like I'm stuck and ask myself that is there any other way to be more nice than I made before? or well structured? or well designed?

Please advice me.

Thank you

Aucun commentaire:

Enregistrer un commentaire