This function captures all jpegs from folders that match the page name and prints the background image. Find all this directory on the homepage and choose one at random. What do I want (only on the homepage) Some files that match an array of names ... Can anyone help?
$ isHome = $ this-> Level (=) = 0; $ Path = 'public / picture / bg /'; If ($ $ islahom) is $ path = $ This- & gt; Slog; $ Homepagefile = URL_PUBLIC.'public / images / bg / '. $ This- & gt; Slug. ' / Main.jpg '; $ Bgimagearray = array (); $ Ister = new directory iterator ($ path); Foreign Currency ($ IN $ as Inline $ fileinfo) {if ($ fileinfo-> isFile () & amp; amp; amp;; preg_match ('\ .jpg $ /', $ fileinfo-> GetFilename ()) & amp;) {$ Bgimagearray [] = "'" $ Fileinfo-> GetFilename () "'"; } And if ($ fileinfo-> isDir () is & amp; $ isHome) {$ iterator2 = New directorytitle ($ path. $ Fileinfo-> getFilename ()); Foreign currency ($ iferator2 $ fileinfo2) {if ($ fileinfo2- & gt; isFile () & amp; amp ;; preg_match ('\ .jpg $ /', $ fileinfo2-> matchfilim ())} {$ bgimagearray [] = "'". $ Fileinfo-> GetFilename () '/' $ Fileinfo2- & gt; GetFilename () "'"; }}}} $ Bgimage = array_rand ($ bgimagearray); In simple words, you need a further condition in in
/ Code> statement when filtering for the item goes to bgimagearray
.
if ($ fileinfo2- & gt; isFile () & amp; amp; amp; .jpg $ / ', $ fileinfo2-> getFilename ()) & amp; ; In_array ($ fileinfo2- & gt; getFilename, $ my_blacklist_array) added) {
On one side: Your code is a bit messy and your work is pretty code structured Can be solved with; However, instead of answering your question, your existing code will be rewritten.
Comments
Post a Comment