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

  • Home
  • SEARCH
  • 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 6606005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:21:00+00:00 2026-05-25T19:21:00+00:00

This is my first attempt at a php script after a few weeks of

  • 0

This is my first attempt at a php script after a few weeks of learning. So basically I am parsing an XML blog feed. First if gets the blog post date and if it matches today’s date based on Los Angeles time zome it will go further and get the current blog post urls for the day. Else it will return “no match”. Upon finding blog posts for today if will gather the url of each post. Now here is my issue no matter what i do it always returns no match on the code i am looking for. I assume its not checking each url but since my knowledge is limited I can be certian. I am trying to search each post for a numerical string with regex and if its found I want to echo that string and end the script or if there is no code found echo a message stating that and also end the script. Also if you found a better way or a more efficient way of rewriting my code to clean it up a bit i welcome that too

/*------------------------------------------------
//XML File and Parsing
------------------------------------------------*/
//XML document 
$rss = simplexml_load_file($xmlfeed);
//Blog Dates
$blogdate = $rss->channel->item;
//Blog URLS
$blogurl = $rss->channel->item;

/*------------------------------------------------
//Date Variables
------------------------------------------------*/
//Original date format: Mon, 26 Sep 2011 22:00:08 +0000
$post_date = $date->pubDate;
//Original date format: September 26 2011
$todays_date = date("F j Y");
$timezone = new DateTimeZone('America/Los_Angeles');
//Format blog post dates into PDT
$date1 = new DateTime($post_date);
$date1->setTimeZone($timezone);
//Output date: September 26 2011
$post_date_final = $date1->format("F j Y");
//Format server date into PDT
$date2 = new DateTime($todays_date);
$date2->setTimeZone($timezone);
//Output date: September 26 2011
$todays_date_final = $date2->format("F j Y");
echo $post_date;
/*------------------------------------------------
//Checking and Looping
------------------------------------------------*/
//Looping through blog dates for a mtach
foreach ($blogdate as $date) {
    //If dates match continue to gather URLs
    if ( $post_date_final == $todays_date_final ) {
        foreach ($blogurl as $url) {
            $postone = $url->guid[0];
            $posttwo = $url->guid[1];
            $postthree = $url->guid[2];
            $postfour = $url->guid[3];
            $postfive = $url->guid[4];
            $postsix = $url->guid[5];
            $go = array($postone, $posttwo, $postthree, $postfour, $postfive, $postsix);

            foreach ($go as $stop){
                $html = file_get_contents($stop);
                preg_match('/cd=\b[0-9]{8,15}\b/', $html, $match);
                $regex_match = $match[0];

                if (isset($regex_match)) {
                    echo $regex_match;
                }else{
                    echo "no match";
                    exit;
                }
            }
        }
    }else{
        echo "no match";
        exit;
    }
}
  • 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-25T19:21:01+00:00Added an answer on May 25, 2026 at 7:21 pm

    I’ve only quickly skimmed over your code but I saw this line which you might want to change:

    if(!isset($regex_match))
    

    It is saying, if $regex_match is not set then echo $regex_match. Meaning if you are trying to echo it when it has not found something.

    Try taking out that ! and see if that helps.

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

Sidebar

Related Questions

First attempt to use this cool site - after searching for 2 hours: So
Ok, so this is my first attempt at setting up an RSS feed. Here
this if my first attempt at using streaming for WCF, and I am struggling
Because this is my first attempt at an extension method that seems quite useful
This is pretty strange (admitedly, this is my first attempt with python / sqlite),
I'm writing an application using DDD techniques. This is my first attempt at a
OK, I'm probably not the first person to attempt to put together a PHP
This is my first attempt at adding ajax to a WordPress plugin. I have
This is my first attempt at AJAX, and I'm running into three specific problems.
Ok, so this is my first attempt at doing anything with JSON. 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.