[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.4

Find if portion of string exists in another string?

Asked by TunaMaxx in PHP Scripting Language

Tags: exists, php, another, find

Sorry if the title is confusing... I can't quite figure out how to word what I am trying to do...

I have written a script that checks a network share to see if a file exists. If it does, the script uses the pre-processed file. If not, file is processed on the spot. It works well except for a recent developement. Here is a brief example of what is going on:

 An unrelated piece of software converts files of one type (file 'A') into files of another (file 'B'). Then the original file ('A') gets treated again by a secondary process (file 'C') which sits and waits for the PHP script to come deal with it. File 'A' is then thrown out, leaving only Files 'B' and 'C' behind.   Everything works well as long as the only thing that changes over the various files is their extension (.eps, .rtl & .tif respectively).

Example:
File A: 12345_File01.eps
File B: 12345_File01.rtl
File C: 12345_File01.tif

However, occasionally file 'B' has some info appended to it name.

Example:
File A: 12345_File01.eps
File B: 12345_File01_#123.rtl
File C: 12345_File01.tif

  The script creates a list of filenames by looking in 'Directory B' and then stripping off their extensions. It then looks in 'Directory C' to see if it can find a matching file (12345_File01). As long as filename 'B' hasn't been altered, it works great. When filename 'B' has been changed, the matching file 'C' can't be found because it hasn't been similarly altered. I can't control the renaming of file 'B' nor can I alter the name of file 'C' to match. In addition, the additional information appended to 'B' changes frequently, as well as what exactly is added. Sometimes it's just a number, other times it's text or any combination of the two.

  Here is a small section of the script so you can see what's going on:

      // Check to see if converted file already exists
      if (!file_exists($file_c)) {

            // Check to see if there is a source tif to be converted
            if (file_exists($file_b)) {
                  // Image Magick follows...
                  $command = "convert \"$file_b\" -quality 85 \"$file_c\"";
                  system( $command );
            } else {
                  die("Woah! I can't find the preview file for {$_GET['file']}.");
            }
      }

What I need to be able to do is, given either:

 "12345_File01"
 OR
 "12345_File01_#123"
 OR
 "12345_File01_Info_#1234"

...to look in a directory and recognize that the file "12345_File01" is the one it is looking for.

Basically, I'm trying to match everything BEFORE the extension of File 'C' (12345_File01 in this case) but given the filename from 'B'

Does this make sense? Is it possible?
[+][-]11/12/05 08:19 AM, ID: 15280079Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: PHP Scripting Language
Tags: exists, php, another, find
Sign Up Now!
Solution Provided By: gerodim
Participating Experts: 4
Solution Grade: A
 
[+][-]11/11/05 01:03 AM, ID: 15272195Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/11/05 01:28 AM, ID: 15272285Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/11/05 01:52 AM, ID: 15272379Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/11/05 01:58 AM, ID: 15272399Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/11/05 09:44 AM, ID: 15275330Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091118-EE-VQP-93