fogofogo Posted February 20, 2006 Share Posted February 20, 2006 Hello folks.I have a question about using php to select a file according to date. I am working on a project that uses xml to display horoscopes on a website. The xml feeds are ftp'd onto our server and have a different file name depending on the date. Unfortunetly this is the only way the xml is available.The filenaming is:Feed_name_YYYYMMDDHHMMSS_$storyid.xmlFor example:TMG_Horoscopes_Daily_Virgo_media_20060216100017_985313.xmlI'll be using php to do this, and as I'm fairly new to it, I'm not sure where to go from here. Does anyone have any advice, scripts or tutorials that might be able to help me?Thanks guys,John Link to comment Share on other sites More sharing options...
hacknsack Posted February 23, 2006 Share Posted February 23, 2006 You could explode the string, then grab the date with substr() $str = 'TMG_Horoscopes_Daily_Virgo_media_20060216100017_985313.xml';$parts = explode("_", $str);$j = count($parts) - 2;echo substr($parts[$j], 0, 8); But I'm not sure exactly what you are asking.-hs Link to comment Share on other sites More sharing options...
DarkElf Posted February 23, 2006 Share Posted February 23, 2006 alternatively if you swapped the date and the $storyid around you could use a regular expression followed by $ symbol to show that it has to match at the end of the string, its pretty much the same thing but uses less code. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now