I'm afraid I have a pretty basic knowledge of PHP.

I've inherited a site with some php as follows:

if ($po = $product->GetLink) {$iext = preg_match ("/dwg/", $po) ? 'dwg' : 'pdf'; ?>

I understand this to be
1. $po is the file name
2. $iext is the value 'dwg' if the string 'dwg' appears in $po
3. else $iext is the value 'pdf'.

This allows me use the value $iext in my html - assiging a css class to the item for styling.

The thing is I would like to allow for more than either .dwg or .pdf files. (.doc, .zip or .bmp for example).

So would I need to write something that does the following:

1. Create an array of file types:

$filetypes = array (
    "filetypes"  => array("dwg" => ".dwg", "pdf" => ".pdf", "zip" => ".zip")

2. See if any values in the array match a string in my $po and declare $iext to be that match.

Something like this..... except this doesn't work.

if (preg_match($filetypes, $po))
   $iext = preg_match ($filetypes, $po); 

Am I way off course?