PHP: How can I separate this split this string correctly? -


i have bunch of url segments.

i know either come in form of:

mystring?var1=value 

or

mystring/name.php?var1=value 

in either case need take url , mystring bit out of it. will:

  1. search either first / or ?
  2. turn whatever came before var , throw rest of string out.

how can achieved?

a simple way it

$parts = explode('?', $str); $parts = explode('/', $parts[0]); $yourfinalstring = $parts[0]; 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -