3

I'm trying to grab this description which is on a website using preg_match just having issues:

Here is what i'm trying to grab. Just the text after <b>Game Description:</b><br /> upto <b>Tool v3.1 Info:

<b>Game Description:</b><br />
Steel Diver is a new action-packed submarine combat game from Nintendo that<br />
immerses players in the 3D action with unique game controls and lush 3D<br />
environments. The player can choose from three different submarines, each<br />
with touch-screen control panels that players will have to master to guide<br />
them through treacherous undersea caverns while engaging enemy submarines,<br />
dodging depth charges and battling massive sea creatures. Steel Diver also<br />
takes advantage of the built-in gyroscope of the Nintendo 3DS system. The<br />
combination of 3D game play and one-of-a-kind controls makes for an immersive<br />
combination that must be experienced to be believed.<br />
<br />
<b>Tool v3.1 Info:

Heres what I've tried:

    $pattern1 = '#<b>Game Description:</b><br />\s*(.*?)\s*<b>Tool v3.1 Info:#';
    preg_match($pattern1,$downloadPage,$description);
    print_r($description);

$downloadPage is just opening the URL using curl, I've got it grabbing some other data, Just need help with this part.

Thanks

5
  • Just use a function like this: stackoverflow.com/a/8010000/2100549 Commented Dec 17, 2013 at 19:13
  • Where do you set the variable $description? Commented Dec 17, 2013 at 19:15
  • Sorry check now, was a typo. How can i make that function work with getting data from a website? Commented Dec 17, 2013 at 19:16
  • @Barmar - $description is the matches array Commented Dec 17, 2013 at 19:17
  • @user602525 He edited the question after I asked. The matches array was $match_description at that time. Commented Dec 17, 2013 at 19:19

1 Answer 1

3

You need the s modifier to match over multiple lines:

$pattern1 = '#<b>Game Description:</b><br />\s*(.*?)\s*<b>Tool v3.1 Info:#s';

Demo.

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.