CUTCODEDOWN
Minimalist Semantic Markup

Welcome Guest
Please Login or Register

If you have registered but not recieved your activation e-mail in a reasonable amount of time, or have issues with using the registration form, please use our Contact Form for assistance. Include both your username and the e-mail you tried to register with.

Author Topic: How to exclude certain file names from php arraydiff and scandir  (Read 69 times)

durangod

  • Full Member
  • ***
  • Posts: 201
  • Karma: +3/-0
  • Weebles Wobble - but they dont fall down!
Hi,

I have been playing around with how to exclude any file name that includes the word thumb so basically
*thumb*   when i get a file list from a dir.   But my attempts are failing...

I am thinking the only way to do it is to use foreach on the result and filter out the file names i dont want.  I dont think i can do it using tthe array_diff command

current code i am skipping the linux  [..] and [.] dir listings
Code: [Select]
$logo_list =  array_diff(scandir(CORE_LOCAL_LOGO_IMAGES), array('..', '.'));

//this did not work
$logo_list =  array_diff(scandir(CORE_LOCAL_LOGO_IMAGES), array('..', '.','*thumb*'));


but how do i also skip *thumb*?   

Update:  best i could come up with is to wait to filter it in my foreach for the html select

Code: [Select]
if(strstr($val, 'thumb') === false)
{
     //not found
}

« Last Edit: 16 Aug 2023, 05:40:24 am by durangod »

Dave

  • Junior Member
  • *
  • Posts: 32
  • Karma: +8/-0
Unless you files with thumb in their names don't have an extension, shouldn't your *thumb* really be *thumb*.* to cover all extensions?
Dave

durangod

  • Full Member
  • ***
  • Posts: 201
  • Karma: +3/-0
  • Weebles Wobble - but they dont fall down!
Re: How to exclude certain file names from php arraydiff and scandir
« Reply #2 on: 19 Nov 2023, 09:57:59 pm »
Yeah that could work, i only allow jpg, gif, png  so im thinking the global would allow too wide a range.

 

SMF spam blocked by CleanTalk

Advertisement