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 6108043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:15:15+00:00 2026-05-23T14:15:15+00:00

Hard question (for me at least) hope someone is able to help me as

  • 0

Hard question (for me at least) hope someone is able to help me as I already got lots of help here before! I have this code to get an actor image from the iMDB site

$string = FetchPage($url);
$image_regex_src_url = '/<td id="img_primary"[^>]*'. 'src=[\"|\'](.*)[\"|\']/Ui';
$img_tag_array = $out[0];
$image_regex_src_url = '/<img[^>]*'.'src=[\"|\'](.*)[\"|\']/Ui';
preg_match_all($image_regex_src_url, $string, $out, PREG_PATTERN_ORDER);
$images_url_array = $out[1];

Take Kevin Costner as example here: http://www.imdb.com/name/nm0000126/

I’m trying to adapt my code to fetch into a variable the integer of oscars won so far from this line: “Won 2 Oscars.” and to another variable his birth date from the lines “Born:Kevin Michael Costner
January 18, 1955 in Lynwood, California, USA”

To end with something like this:

$actor_oscars = 2;
$actor_birthdate = "January 18, 1955";

The thing is, my knowledge of Regular Expressions is very very limited and I already tried to make this alone (on a trial and error basis) and failed completely! Any good soul out there to help me?

PS: I tried to put the code here on stackoverflow to look pretty but even with that I seem not to succeed at all!

Thanks in advance!

  • 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-05-23T14:15:15+00:00Added an answer on May 23, 2026 at 2:15 pm

    After each preg_match line $matches[1] will contain the desired result

    Image URL:

    preg_match( '/<td[^>]*id="img_primary".+?<img[^>]*src="([^"]+)"/s', $str, $matches );
    

    Oscars Won:

    preg_match( '/Won\s(\d+)\sOscars\./', $str, $matches );
    

    Birth Month-Day:

    preg_match( '/<a href="[^"]*birth_monthday[^"]*">(.+?)<\/a>/', $str, $matches );
    

    Birth Year:

    preg_match( '/<a href="[^"]+birth_year[^"]+">(.+?)<\/a>/', $str, $matches );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a very hard to explain question and I hope my code extract
I have tried to ask a variant of this question before. I got some
This question is hard to describe succinctly, so bear with me. Currently I have
This question is hard to phrase, so I'm going to have to use some
this is really hard question. I have an exam. And questions will be like
Overflow :3 I've got a kind of hard-case question. So I'll try clearly explain
This question's solution makes hard-coded transformation of a sample XML tree into a flat
This question is more UI/Design-ish than hard-core programming is. Background: I've been coding in
Now the question is pretty hard. Now this is my main list List<List<KeyValuePair<string, double>>>
I know this question has been asked quite a few times, however, I have

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.