473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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!

http://www.codershangout.com

Jan 18 '07 #1
3 1190

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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Aleksandar Matijaca | last post by:
Hi there, I am in some need of help. I am trying to parse using the apache sax parser a file that has vaid UTF-8 characters - I keep end up getting a sun.io.MalformedInputException error. ...
16
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed...
12
by: BGP | last post by:
I am working on a WIN32 API app using devc++4992 that will accept Dow Jones/NASDAQ/etc. stock prices as input, parse them, and do things with it. The user can just cut and paste back prices into a...
8
by: Andrew Poulos | last post by:
I've have a number of DIV tags that contain one image. Each DIV has an onclick event. How can I get the image filename? I just need the filename and not the file path. I was trying to do...
0
by: Marc van Boven | last post by:
I'm stuck with the following problem: My nusoap-client calls a server-function giveCombination(). The function giveCombination should return something like array( => array( 'a_id' => 6,...
5
by: bmichel | last post by:
Hey, What I'm doing is the following: - Load XML data a file - Parsing the XML data - Printing some parsed content The problem is that the script execution is stopping before all the...
13
by: Chris Carlen | last post by:
Hi: Having completed enough serial driver code for a TMS320F2812 microcontroller to talk to a terminal, I am now trying different approaches to command interpretation. I have a very simple...
6
by: Reggie | last post by:
am trying to associate username with filename in a upload script. I get this error: Parse error: syntax error, unexpected T_STRING in /home/fhlinux169/c/ clashoff.co.uk/user/htdocs/upload.php...
0
by: HalfCoded | last post by:
hi everyone, I am kind of stuck and therefore would really appreciate some clues: I actually have to run a script which has to compare two elements from two different files which are a blast...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.