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.

1 Answer 1

4
unset($matches);
preg_match_all('/<a href="[^"]+\.pdf">/',$text,$matches);
foreach ($matches as $match)
{
    $shiz = $match[0];
    // Your code here ...
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.