Page 1 of 1

Find all links and return the one matching a regex

Posted: Tue Mar 13, 2007 2:53 pm
by SamF
Hi all,

I'm a java programmer who is using a web-based CVS and build system. What this means is that all my programs get stored on a page like this one: http://jnlp.concord.org/jnlp/org.concord/. As you can see, for every program (.jar file), there are a number of versions with increasing version numbers.

I occasionally write applets that need to reference the jars directly in a link that looks somewhat like this: http://jnlp.concord.org/jnlp/org.concor ... .230140-11

As you can see, the link contains the version number inside of it.

However, this means thast if I want my applets to stay up-to-date with my jar, I need to keep updating the static link.

It would be great if instead of linking to http://jnlp.concord.org/jnlp/org.concor ... .230140-11 I instead just linked to http://jnlp.concord.org/latestjar.php?type=datagraph, or something (forgive me if the syntax is completely off, I'm a PHP newbie).

Is there a way to create a PHP file, and have it return a link that 1) matches some regex, so I can specify the jarr file, and 2) returns the latest version, by looking at the version number?

Any advice of hints would be greatly appreciated!
Sam

Posted: Tue Mar 13, 2007 2:59 pm
by Burrito
Moved to regex

Posted: Wed Mar 14, 2007 1:11 am
by Kieran Huggins
sure you can - check out preg_match() and header('location: redirect.to.latest.file.jar')

Posted: Wed Mar 14, 2007 8:51 am
by John Cartwright
you could likely use glob() in this instance too if not for it's pattern matching, atleast collecting filenames in a directory