PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 25th, 2012, 02:04 AM
ravi00991 ravi00991 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Posts: 1 ravi00991 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 17 sec
Reputation Power: 0
General - Php code help

I have over 5000 files in a directory. and if they contain "-XXX.jpg" I want to do something with them.
The below code.. kind of works but not quite accurately.

is there any easier way .. a way that will definitely work.



$array = Array(
0 => '-1.jpg',
1 => '-2.jpg',
2 => '-3.jpg',
3 => '-4.jpg',
4 => '-5.jpg',
5 => '-6.jpg',
6 => '-7.jpg',
7 => '-8.jpg',
8 => '-9.jpg',
9 => '-10.jpg',
10 => '-11.jpg',
11 => '-12.jpg',
12 => '-13.jpg',
13 => '-14.jpg',
14 => '-15.jpg',
15 => '-16.jpg',
16 => '-17.jpg',
17 => '-18.jpg',
18 => '-19.jpg',
19 => '-20.jpg',
20 => '-30.jpg'
);

if ($handle = opendir('/skin-batcher/omgz')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$filename = '/skin-batcher/omgz/$file';
$id = time( ); // filename




foreach ( $array as $needle ) {
if (strpos($file,$needle) !== false) {
echo $file;
}

}

}
}
closedir($handle);
}
?>

Reply With Quote
  #2  
Old June 25th, 2012, 10:07 AM
jamespayne jamespayne is offline
Administrator
Developer Shed Admin.
 
Join Date: Sep 2008
Location: South Florida
Posts: 12 jamespayne User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 10 h 16 m 32 sec
Reputation Power: 10
Send a message via Yahoo to jamespayne
Hi,

You might also want to try to ask this question over at our sister forum, www.forums.devshed.com. You will have to create a new login there, but you might get a quicker response. We have a lot of PHP professionals there that can assist you.

Hope to see you there!

Reply With Quote
  #3  
Old January 21st, 2013, 05:44 PM
kpalmer29852 kpalmer29852 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 2 kpalmer29852 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 58 sec
Reputation Power: 0
I will try that too. Thank you. I'm just having some serious issues with this.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > General - Php code help


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap