开发者

preg_match to array. PHP

Calling all the PHP helpers ou开发者_运维技巧t 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.


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜