mercredi 18 décembre 2019

How can convert query string in laravel to json

I have a problem here, I want to change the query string that I received to the json form as follows

{"id":"89"}

here I try to use json_encode but the one it produces is

""?id=89""

here is my code

    $coba = str_replace($request->url(), '',$request->fullUrl());
        if (empty($coba)) {
           $url = "{}";
        } else {
            $url = $coba;
        }

         $json_body = json_encode($url);

there I also want to change if there is no query string then the result is {}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire