Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9031221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:40:36+00:00 2026-06-16T07:40:36+00:00

I make a simple application to take recipe info from websites like allrecipes.com. I’m

  • 0

I make a simple application to take recipe info from websites like allrecipes.com. I’m using preg_match, but something is not working.

$geturl = file_get_contents("http://allrecipes.com/Recipe/Brown-Sugar-Smokies/Detail.aspx?src=rotd");
          preg_match('#<title>(.*) - Allrecipes.com</title>#', $geturl, $match);
          $name = $match[1];
          echo $name;

I’m just trying to take the title of the page (minus the - Allrecipes.com part) and put it into a variable, but all that turns up is blank.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T07:40:38+00:00Added an answer on June 16, 2026 at 7:40 am

    There were two problems in this pattern. First, there was a newline symbol after the <title> which wasn’t captured by . (as without /s modifier . is literally ‘any symbol but EOL one’). Second, the Allrecipes.com text was actually NOT followed by </title> substring, there was a newline separating them.

    Taking into account the fact that \s covers both normal whitespace and line separating one, you can just alter your regex like this:

    '#<title>\s*(.*?) - Allrecipes.com\s*</title>#s'
    

    /s modifier is not actually relevant here (cudos to minitech for noticing that), as the title in this recipe is one-line, and all “\n” symbols will be covered by \s* subexpression. But I’d still suggest leaving it there, so that multi-line titles won’t catch you off-guard.

    I’ve replaced .* with .*? for efficiency sake here: as the string you’re looking for is quite short, it makes sense to use non-greedy quantifier here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a very simple django upload application but I want to make it
I am trying to make a simple Client-Server application but when I execute the
I followed the tutorial from this site: http://theappleblog.com/2008/08/04/tutorial-build-a-simple-rss-reader-for-iphone/ to make my first iPhone application,
I want to make a simple application that will take in: number of students
I am trying to make simple notepad application for learning android development. So, to
I am trying to make a simple application which will send the user to
I am trying to make a simple application that turns a character to look
I have a relatively simple application which I need to make native Mac OSX
I have a very simple application and I cannot make the WebView to show
I am working on an application. To make simple, it has this design :

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.