Welcome Guest, Not a member yet? Register   Sign In
how to read files from the directory without get_filesnames()
#4

[eluser]TheFuzzy0ne[/eluser]
Here's how I would do it, although I can think of at least 10 more ways of doing it.

Code:
<?php

function append_suffix($filename, $suffix="")
{
    $filename = explode('.', $filename);
    $filename[count($filename)-2] = $filename[count($filename)-2] . $suffix;
    return implode('.', $filename);
}

$suffix = '_cr';
$filename = "somefile.jpg";
echo append_suffix($filename, $suffix); # echoes somefile_cr.jpg


Messages In This Thread
how to read files from the directory without get_filesnames() - by El Forum - 04-22-2009, 12:59 PM



Theme © iAndrew 2016 - Forum software by © MyBB