I have a url goes like this:
https://sitename.com/nhd/my_student/nhd?olympiad=4
And by using \Request::getQueryString()
, I get this string value:
olympiad=4
Now I need to get only the number 4 from this string.
How can I do that?
CodePudding user response:
use request query method
request()->query('olympiad');
or
$request->query('olympiad');
Also query($key = null, $default = null)
method accept default value as second param.
To get all query params use $request->query()
so you get all query params in array.
Ref: https://laravel.com/docs/8.x/requests#retrieving-input-from-the-query-string