I'm trying to use preg_match to extract info from
href="domain.com/subdir/?key=value
The info I want are
- domain.com
- subdir
- key
- value
Can someone suggest what is the correct way to write the preg_match statement?
Thanks!
I'm trying to use preg_match to extract info from
href="domain.com/subdir/?key=value
The info I want are
Can someone suggest what is the correct way to write the preg_match statement?
Thanks!
use this as your regex
/href="(.+..+?)\/(.+?)\/(\?.+?=.+)"/
that should work
preg_match('/href="(.+\..+?)\/(.+?)\/(\?.+?=.+)"/', $input, $matches);
echo "First Match: {$matches[0]}\n";