Reputation: 11
Hi i really cant find the answer. i got a couple variable that i wanna use in a preg_match but i only can use one variable.
my code is:
function imagetoday(){
global $imagetoday;
if(preg_match_all('/rain.png/', $imagetoday)){
echo '<img src="assets/img/rain.png" class="img-responsive week" alt="Responsive image">';
}
if(preg_match('/light_rain.png/', $imagetoday)){
echo '<img src="assets/img/light_rain.png" class="img-responsive week" alt="Responsive image">';
}
if(preg_match('/partly_cloudy.png/', $imagetoday)){
echo '<img src="assets/img/partly_cloudy.png" class="img-responsive week" alt="Responsive image">';
}
}
i tried to use
if(preg_match('/light_rain.png/', $imagetoday, $imageday2, imageday3, $imageday4)){
echo '<img src="assets/img/light_rain.png" class="img-responsive week" alt="Responsive image">';
}
but doesnt work can someone help me please? thanks!
Upvotes: 0
Views: 1488
Reputation: 89547
like this:
if (preg_match('/(?:(?:light_)?rain|partly_cloudy)\.png/', $imagetoday, $match)) {
echo '<img src="assets/img/' . $match[0]
. '" class="img-responsive week" alt="Responsive image">';
}
Upvotes: 1