- preg_match: documentation ( source)
- print_r: documentation ( source)
<?php
preg_match(
'/
\\s+ # whitespace
href # "href" attribute
\\s* # optional whitespace
= # literal "="
\\s* # optional whitespace
(["\']) # open quote (captured for later backreference)
([^"\']+)
\\1 # the same quote character as the opening quote
/x',
'href="/"',
$matches
);
print_r($matches);