Jump to content

simple regex


SchweppesAle

Recommended Posts

I'm guessing that preg_match() can't find a match due to the slashes in image path. Here's a var_dump from each variable.  Element 4 of bannerImages should be match, I'm not having any luck though.

 

$bannerData vardump:

array(8) { ["id"]=> string(2) "26" ["title"]=> string(7) "banner2" ["img_location"]=> string(59) "http://localhost/Joomla1.5/images/banners/iP4600_banner.jpg" ["expiration_date"]=> string(10) "2009-12-31" ["start_date"]=> string(10) "2009-12-22" ["destination"]=> string(20) "http://www.yahoo.com" ["published"]=> string(1) "1" ["locations"]=> string(1) "1" }

 

 

/*yea, i need to fix that image path, i noticed*/

 

var_dump($bannerImages):

array(10) { [0]=> string(41) "../images/banners/Bakers-banner_large.jpg" [1]=> string(45) "../images/banners/TheFalconBanner-PodCast.gif" [2]=> string(28) "../images/banners/banner.jpg" [3]=> string(40) "../images/banners/banners_mtd_728x90.gif" [4]=> string(35) "../images/banners/iP4600_banner.jpg" [5]=> string(28) "../images/banners/index.html" [6]=> string(32) "../images/banners/osmbanner1.png" [7]=> string(32) "../images/banners/osmbanner2.png" [8]=> string(35) "../images/banners/shop-ad-books.jpg" [9]=> string(29) "../images/banners/shop-ad.jpg" }

 

 

It looks simple :shrug:

foreach($bannerImages as $banner)
                {
                    if(preg_match("/$banner/",$bannerData['img_location']))
                        {
                            echo '<option SELECTED>'.$banner.'</option>';
                        }
                        else
                    echo '<option>'.$banner.'</option>';
                }

Link to comment
https://forums.phpfreaks.com/topic/186216-simple-regex/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.