1

Calling all the PHP helpers out there.

So basically I would like to give the function preg_match a variable that can contain a couple thousand lines of code) and have it search using a wildcard + strings either side of the widlcard.

For example I would like to search for strings that look like this <a href="*.pdf">

I would then like the function to return every match (along with the html shiz around the wildcard, this is to catch any directory structures too) in an array that I can loop through using a foreach(){} loop.

I'm guessing this is possible, would anyone have the time to help me with this?

I've check through all the preg_match lit' and through the answers on here, but I can't seem to get the patterns correct. Thanks in advance.

Peace out.

shane
  • 13
  • 1
  • 3

1 Answers1

4
unset($matches);
preg_match_all('/<a href="[^"]+\.pdf">/',$text,$matches);
foreach ($matches as $match)
{
    $shiz = $match[0];
    // Your code here ...
}
AndreKR
  • 32,613
  • 18
  • 106
  • 168