troubleshooting Question

Detecting and changing strings in PHP

Avatar of DrZork101
DrZork101 asked on
PHP
12 Comments1 Solution220 ViewsLast Modified:
I want to detect the structure of a string and according to how it is structured, change the string.

The four types of structure are as follows:

1 - "Product Name [DVD] [2000]"
2 - "Product Name [DVD]"
3 - "Product Name [2000]"
4 - "Product Name"

And the four transformations would be:

1 - "Product Name [DVD]"
2 - "Product Name [DVD]"
3 - "Product Name" . $variable
3 - "Product Name" . $variable

The part of the string [DVD] will always be in the form [ + any number of characters + ]
The part of the string [2000] aill always be in the form [ + 4 numeric characters + ]

What is the most efficient way to do this - speed is a high priority?

Thanks,
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 12 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros