Re: a little trickery

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Sep 8, 2012 at 10:49 AM, Stuart Dallas <stuart@xxxxxxxx> wrote:
>
> Is there just one image in the folder that starts with the 9 digit number? In that case it's dead simple (untested code):
>
> <?php
>   function completeImageFilename($prefix)
>   {
>     $matches = glob('images/property_pics/'.$prefix.'*');
>     return $matches[0];
>   }
>
>   echo '<img src="'.completeImageFilename($row['MSL_No']).'" />';
> ?>

    Stuart is, as usual, right on.  Rather than do the filesystem
handlers and loops, you should definitely consider glob().  Not only
is it quicker, cleaner, and easier to use, but it's far less
resource-intensive than your current implementation.

-- 
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux