By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,049 Members | 1,308 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,049 IT Pros & Developers. It's quick & easy.

filename parsing....stuck!

P: n/a
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!

http://www.codershangout.com

Jan 18 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a

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

Jan 18 '07 #2

P: n/a
Arg!

In this code:

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

$pattern = '/\d+/';

$matches = preg_split($pattern, $fn, -1, PREG_SPLIT_NO_EMPTY);

print_r($matches);
give me:

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

why do I not get 640 480??

http://www.codershangout.com

Jan 18 '07 #3

P: n/a
Nevermind!

I'm an idiot.

It's D not d

http://www.codershangout.com
cbmeeks wrote:
Arg!

In this code:

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

$pattern = '/\d+/';

$matches = preg_split($pattern, $fn, -1, PREG_SPLIT_NO_EMPTY);

print_r($matches);
give me:

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

why do I not get 640 480??

http://www.codershangout.com
Jan 18 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.