whats wrong with this below ?
Main Topics
Browse All TopicsI'm trying to get the starting year and ending year of the following $input string.
I would like
$matches[0]=92
$matches[1]=95
or if it's the product has a 4 digit year, like 1992-1995 then I would like:
$matches[0]=1992
$matches[1]=1995
For some reason it looks like my explode isn't working. Also my REGEX might be totally wrong.
Please check it out, thanks!
Basically I'm trying to extract the starting and ending year out of a product title.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I've attached a fixed version of what you were trying to do.
PHP's "explode" function takes a string and converts it into an array. In line #7 of your original code, you were trying to explode "$matches", an array (versus a string).
In order to use "explode", you need to use a string, "$matches[0][0]".
Hello www_puertoricoautoforo_com
The latest code from asafadis (ID:25772573) work great
I give you my advice if you want to know what is "wrong" in your regex to do the following :
$matches[0]=1992
$matches[1]=1995
or
$matches[0]=92
$matches[1]=95
You are searching for 1992-1995 and not (1992) | (-1995) so you get only one result and not two and need to explode after that. It's too late.
Regards.
Business Accounts
Answer for Membership
by: asafadisPosted on 2009-11-07 at 20:29:32ID: 25769397
See if this works for you:
Select allOpen in new window