View Full Version : Checking for letters

05-20-2004, 04:32 AM
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:


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:

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!

05-20-2004, 07:23 AM
wouldn't it make more sense to make a 3D array? like

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

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

to split up the filename --> that's quite easy.

$filename = '03_09.jpg'; // in your script, you'll have the value set inside a loop
list ($stripNumber, $extension) = explode ('.', $filename);
if (substr($stripNumber, -1) == 'M'){
$stripNumber=substr($stripNumber, 0, -1);
$yourarray[] = array('misc'=>$misc, 'stripNumber'=>$stripNumber, 'extension'=>$extension);

05-22-2004, 01:08 AM
Sorry for the late reply...

Anyway, THANK YOU! :D

05-22-2004, 01:46 AM
You're welcome.

(note : i missed a ; after the $misc=True ... )

05-22-2004, 01:55 AM
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. :confused:

05-22-2004, 02:02 AM
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)