0

I have a series of strings created as URLs as the page gets refreshed.I want to remove a portion from the right side of these strings. The strings look like:

http://funfun.ca/?image=1
http://funfun.ca/?image=14
http://funfun.ca/?image=217

and so on. The goal is for anything starting with "?" to be removed from the right side of the strings and leave the following for all of them:

http://funfun.ca/

I appreciate any help I can have to solve this

DocZ
  • 11

1 Answers1

0

You may explode the url string for ? and save only the first part obtained:

$firstPart = explode('?', $url)[0];

Example:

echo $firstPart = explode('?', 'http://funfun.ca/?image=1')[0];

returns:

http://funfun.ca/
user2342558
  • 5,567
  • 5
  • 33
  • 54