I don't have much knowledge in PHP, your help appreciated.
I created a database query and foreach loop in PHP for getting data from database, Here is my foreach code:
if($user->id != 0)
{
foreach ( $results as $result) {
$leftday = $result->dayleft;
$subsexp = "-";
if( strpos( $leftday, $subsexp ) !== false ) {
echo "Subscription Expired<br>";
} else {
echo "Subscription Active<br>";
}
}
}
Here the result as expected:
- Subscription Expired
- Subscription Expired
- Subscription Active
- Subscription Active
But how can I show only one "Subscription Expired" text when there are no any "Subscription Active"? Now it's showing 4 times "Subscription Expired" text when all subscription expired.