How can I get the value of the parameter after # character? The Get URI of third party API is http://example.com/product?name=abc#cde
. I am only getting data of name params as 'abc'
. How can I get full value as 'abc#cde' in laravel.
Asked
Active
Viewed 250 times
0

Ramin eghbalian
- 2,348
- 1
- 16
- 36

Ankur Mishra
- 1,284
- 1
- 6
- 15
-
1https://stackoverflow.com/questions/967649/get-entire-url-including-query-string-and-anchor#967659 – coderman401 Feb 03 '20 at 04:28
-
@Coderman it did not solve my problem as I have to get data from third party url. – Ankur Mishra Feb 03 '20 at 04:34
-
you can use `url()->full()` that will return the full url including the `#`. But treating `#` as value of a parameter, that complicates. you can check more url helpers here https://laravel.com/docs/6.x/urls – tempra Feb 03 '20 at 05:49
-
Does this answer your question? [Get fragment (value after hash '#') from a URL in php](https://stackoverflow.com/questions/2317508/get-fragment-value-after-hash-from-a-url-in-php) – Calos Feb 03 '20 at 07:12
1 Answers
0
As I understand, you have a URL as a string and would like to extract the bit after #
. You don't need Laravel for that, you can achieve it with pure PHP as following:
$url_string = 'http://example.com/product?name=abc#cde';
$url = parse_url($url_string);
echo $url['fragment']; // 'cde'

Aydin4ik
- 1,782
- 1
- 14
- 19