Daniel
Daniel

Reputation: 4342

match string with if statement

I am trying to match two strings and if there is a match state that a match was found. The strings I am comparing are dates using the following code.

$feed = simplexml_load_file('http://feeds.feedburner.com/2dopeboyz');
foreach($feed->channel->item as $item) {
    $title = $item->title;
    $description = $item->description;
    $pubdate = $item->pubDate;
    $newDate = date("mdY", strtotime(str_replace("UT", "", $pubdate)));
    date_default_timezone_set('America/Los_Angeles');
    $today = date("mdY");

    if ($newdate == $today) {
        echo 'Match!';
    } else {
        echo "No Match!";
    }
}

My problem is that ever string returns no match even when the strings are the same. How can I get this working?

Upvotes: 0

Views: 57

Answers (1)

Dogbert
Dogbert

Reputation: 222198

Change

if ($newdate == $today) {

to

if ($newDate == $today) {
        ^ this

as you're actually declaring $newDate.

Upvotes: 4

Related Questions