(PHP)如果变量等于HTML输出,请执行此操作

I have a script outputting the current day of the week into a HTML span element.

I'd like to find out which day is being inserted into that span element, and show information accordingly. So if "Sunday" is being inserted into the span element, I'd like the text "9AM - 5PM" to be listed. If "Monday" is being inserted into the span, I'd like the text "7AM - 7PM" to be listed. I'll be doing this for each day of the week.

Here is my code:

<?php
    $date = '<span id="date"></span>';
    if ($date == 'Sunday') {
        echo '9AM - 5PM';
    } elseif ($date == 'Monday') {
        echo '7AM - 7PM';
    }
?>

I can't get this code to work with me. Any help is appreciated.

Well i suppose there are several ways to solve your problem (jQuery). But if you want to use Php you could use PHP Simple HTML DOM Parser. You need to download one php file called simple_html_dom.php you can do that here and there is manual how to use this in section Download & Documents.

Here is the code for your problem you just need adapt it to suit your files name and location of files.

<?php
    include('simple_html_dom.php');

    $html = file_get_html('YourHtmlFileName.html');

    $date = $html->find('span[id=date]', 0);

    if($date->innertext = 'Sunday')
        echo '9AM - 5PM';
    else
        echo '7AM - 7PM';
?>