filename parsing....stuck!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cbmeeks

    filename parsing....stuck!

    I'm a newbie to PHP.

    What I am trying to do is take a filename from a URL
    (http://example.com/?i=image-t.jpg) and dynamically re-size it based on
    the "-t"

    For example, I have an original image that is called "image.jpg"

    If someone changes the URL to point to: "image-t.jpg" I want to parse
    the "-t", resize it to a thumbnail and display that.

    I have the resizing down so no problem there. I just can't wrap my
    head around regular expressions.

    Thanks!



  • Sonnich

    #2
    Re: filename parsing....stuc k!


    cbmeeks wrote:
    I'm a newbie to PHP.
    >
    What I am trying to do is take a filename from a URL
    (http://example.com/?i=image-t.jpg) and dynamically re-size it based on
    the "-t"
    >
    For example, I have an original image that is called "image.jpg"
    >
    If someone changes the URL to point to: "image-t.jpg" I want to parse
    the "-t", resize it to a thumbnail and display that.
    >
    I have the resizing down so no problem there. I just can't wrap my
    head around regular expressions.
    Take a look at substr and strpos. That should do it. If you dont know
    them, then look at www.php.net

    BR
    S

    Comment

    • cbmeeks

      #3
      Re: filename parsing....stuc k!

      Arg!

      In this code:

      $fn = 'demo-640x480.jpg';

      $pattern = '/\d+/';

      $matches = preg_split($pat tern, $fn, -1, PREG_SPLIT_NO_E MPTY);

      print_r($matche s);


      give me:

      Array ( [0] =demo- [1] =x [2] =.jpg )

      why do I not get 640 480??





      Comment

      • cbmeeks

        #4
        Re: filename parsing....stuc k!

        Nevermind!

        I'm an idiot.

        It's D not d




        cbmeeks wrote:
        Arg!
        >
        In this code:
        >
        $fn = 'demo-640x480.jpg';
        >
        $pattern = '/\d+/';
        >
        $matches = preg_split($pat tern, $fn, -1, PREG_SPLIT_NO_E MPTY);
        >
        print_r($matche s);
        >
        >
        give me:
        >
        Array ( [0] =demo- [1] =x [2] =.jpg )
        >
        why do I not get 640 480??
        >
        >
        >
        http://www.codershangout.com

        Comment

        Working...