Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jan 2004
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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!

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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); 
    Last edited by raf; 05-22-2004 at 01:46 AM.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #3
    Regular Coder
    Join Date
    Jan 2004
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry for the late reply...

    Anyway, THANK YOU!

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #5
    Regular Coder
    Join Date
    Jan 2004
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #6
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    check that thread ( an odd array problem ) --> 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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •