[UPHPU] Help me speed this up. Possibly a regex question?

Ash ashovi at qwest.net
Tue Feb 12 16:35:34 MST 2008


Is there a faster way to do this? Explanation below if this doesn't make 
sense.

  $infile = "J-$Month-rs.pdf";

if (!file_exists($infile)){
  $infile = "J-$Month-rp.pdf";
         }
if (!file_exists($infile)){
  $infile = "J-$Month-ms.pdf";
         }
if (!file_exists($infile)){
  $infile = "J-$Month-mp.pdf";
         }
if (!file_exists($infile)){
  $infile = "J-$Month-rx.pdf";
         }
if (!file_exists($infile)){
  $infile = "J-$Month-mx.pdf";
         }
if (!file_exists($infile)){
  $infile = "J-$Month-xs.pdf";
         }
if (!file_exists($infile)){
  $infile = "J-$Month-xp.pdf";
         }
if (!file_exists($infile)){
  $infile = "J-$Month-xx.pdf";
         }

We have messages saved as images we put on a person's postcard according 
to whether they are real estate or mortgage, or whether there is a 
single photo or plural photos. See where it says J-$Month-rp? The rp 
mean real estate plural. ms=Mortgage Singular, rx=real estate plural or 
singular, mx=mortgage plural or singular, xx = either real estate or 
mortgage, and either plural or singular. This all has to do with 
grammar, ie, you would say "We'd love to help sell your home" if it is a 
real estate team, whereas you'd put "I'd love to do your mortgage" if it 
is a one-person mortgage card.

But if the message is something like "That was funny, huh?" It would get 
an xx delineation, because the industry (mortgage or real estate) and 
whether they are a singular person or a team doesn't matter in the message.

So I need it to go in this order-- first check if there is an r or m in 
the first place and if there's also a p or s in the second place, if so 
use the mp or rs message. If none of those are right, then we check to 
see if there's a r or m in the first place and an x in the second place 
or x in the first place and P or S in the second place, then use that 
correct message. If none of those are there, use xx.

Is there a better way to do this with some regex magic or something?

Ash


More information about the UPHPU mailing list