mercredi 1 février 2017

PHP for each - else always returns else value

Im using the code below to send a report however when i add the else statement that is all that is returned even when the if statement is true.

can anyone explain why this? i dont think ive ever had this issue before?

        foreach ( $result as $page ) {
            $date1 = new DateTime($page->start_date);
            $date2 = new DateTime($page->end_date);

            if (strtotime($page->start_date) >= strtotime('today') && strtotime($page->start_date) < strtotime('last day of this month')) {

            $email_content .=  '<span style=" background-colour: #777777; font-size: 1em; font-family: arial, sans-serif; color:#202020;"><strong>' . $page->post_title . ' </strong></span>';

            $email_content .=  '<span style=" font-size: 1em; font-family: arial, sans-serif; color:#00b200;"><strong>Order By '  . $date1->format('d-m-y') . ' ' . '</strong></span>';

            $email_content .=  '<div style="  font-size: 1em; font-family: arial, sans-serif; color:#cc0000;"><strong>For Delivery '  . $date2->format('d-m-y') . '</strong></div><br>' . '<br>';

        }
            else {
                $email_content =  '<span style=" background-colour: #777777; font-size: 1em; font-family: arial, sans-serif; color:#202020;"><strong>tester </strong></span>';
            }
        }    

thanks for reading :)

Aucun commentaire:

Enregistrer un commentaire