Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-20-2004, 04:32 AM   PM User | #1
Raraken
Regular Coder

 
Join Date: Jan 2004
Posts: 107
Thanks: 0
Thanked 0 Times in 0 Posts
Raraken is an unknown quantity at this point
Checking for letters

I'm working on a comic display system, and anyway, I need to check (and return) 3 things. Heres some examples of what they would look like:

01_17M.jpg
03_09.jpg
12_04M.gif
02_47.gif

I need to break up the strings 3 ways.
- For the comic number (it will output a string) its the ##_## part
- For the comic's extension (either .jpg or gif) (to output a sting) duh.
- For the letter M at the end of the name. (output as a boolean) on occasion, a comic may be a filler or somthing weird that way. those strips will receive an "M" on the end of their name. (I'll treat them diffrently)

Now, I already have everythin worked out, heres the info on what you need:

-The array of files is in alphabetical order, the array is named "strips"
-I need 3 output array's (prefably named: "stripnumber", "misc", "extension")
-stripnumber wil be a string, misc is a boolean (wether or not it has an "M"), and extension is another string

so heres 3 comics:
02_01.jpg
01_01.jpg
01_02M.gif

they get stored like this (and orginized to be in proper order), I already have this done, btw:
strips[0] = "01_01.jpg"
strips[1] = "01_02M.gif"
strips[2] = "02_01.jpg"

This is what I need help on, I need to have the code to make these (from the strings in the previous array):

stripNumber[0] = "01_01"
stripNumber[1] = "01_02"
stripNumber[2] = "02_01"
misc[0] = false
misc[1] = true
misc[2] = false
extension[0] = ".jpg"
extension[1] = ".gif"
extension[2] = ".jpg"

sorry if I explained poorly. But thank you for any help!
Raraken is offline   Reply With Quote
Old 05-20-2004, 07:23 AM   PM User | #2
raf
Master Coder


 
Join Date: Jul 2002
Posts: 6,589
Thanks: 0
Thanked 0 Times in 0 Posts
raf will become famous soon enoughraf will become famous soon enough
wouldn't it make more sense to make a 3D array? like

$array[0]['stripNumber'] = ...
$array[0]['misc']=...
$array[0]['extension']=...

$array[0]['stripNumber'] = ...
$array[1]['misc']=...
$array[2]['extension']=...


to split up the filename --> that's quite easy.
PHP Code:
$filename '03_09.jpg';  // in your script, you'll have the value set inside a loop
$misc=False;
list (
$stripNumber,  $extension) = explode ('.'$filename);
if (
substr($stripNumber, -1) == 'M'){
   
$misc=True;
   
$stripNumber=substr($stripNumber0, -1);
}
$yourarray[] = array('misc'=>$misc'stripNumber'=>$stripNumber'extension'=>$extension); 
__________________
Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

Last edited by raf; 05-22-2004 at 01:46 AM..
raf is offline   Reply With Quote
Old 05-22-2004, 01:08 AM   PM User | #3
Raraken
Regular Coder

 
Join Date: Jan 2004
Posts: 107
Thanks: 0
Thanked 0 Times in 0 Posts
Raraken is an unknown quantity at this point
Sorry for the late reply...

Anyway, THANK YOU!
Raraken is offline   Reply With Quote
Old 05-22-2004, 01:46 AM   PM User | #4
raf
Master Coder


 
Join Date: Jul 2002
Posts: 6,589
Thanks: 0
Thanked 0 Times in 0 Posts
raf will become famous soon enoughraf will become famous soon enough
You're welcome.

(note : i missed a ; after the $misc=True ... )
__________________
Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html
raf is offline   Reply With Quote
Old 05-22-2004, 01:55 AM   PM User | #5
Raraken
Regular Coder

 
Join Date: Jan 2004
Posts: 107
Thanks: 0
Thanked 0 Times in 0 Posts
Raraken is an unknown quantity at this point
Quote:
Originally Posted by raf
You're welcome.

(note : i missed a ; after the $misc=True ... )
Yes, but it was very helpful.

I'm just having trouble, I posted the comic-array code (and some more) in the other thread, because I'm having troubles. The first two array values are always blank for some reason.
Raraken is offline   Reply With Quote
Old 05-22-2004, 02:02 AM   PM User | #6
raf
Master Coder


 
Join Date: Jul 2002
Posts: 6,589
Thanks: 0
Thanked 0 Times in 0 Posts
raf will become famous soon enoughraf will become famous soon enough
check that thread ( http://www.codingforums.com/showthread.php?t=39048 ) --> it's becaue the first two entrys are the current dir and the parent dir. Posted the code you need there. (basically copy and paste from the manual)
__________________
Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html
raf is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:40 PM.


Advertisement
Log in to turn off these ads.