mysql - How do I remove the query string in PHP?
Solution:
PHP provides a nice helper method called parse_url
to get certain parts of an url:
// $actual_link = 'www.stackoverflow.com/test';
$urlParts = parse_url($actual_link);
$formattedUrl = $urlParts['host']; // www.stackoverflow.com
Docs: https://www.php.net/manual/en/function.parse-url.php
Answer
Solution:
Use strtok()
like this: $baseUrl = strtok($actual_link, '?');