|
Posted by Pedro Graca on 10/12/06 16:17
frizzle wrote:
> Imagine the filename is index_en.html
> My output needs to be an array with the following:
> language => en (no underscore)
> file => index (no "_en")
> extension => html
>
> i created the following, but i don't know how to move on:
> preg_split( '/^[a-z0-9]*(_(en|_ru))?\.[a-z0-9]{2,4}$/', $filename );
preg_match() is your friend.
if (preg_match('/^([a-z0-9]*)(?:_(en|ru))?\.([a-z0-9]{2,4})$/', $filename, $matches)) {
$output['language'] = $matches[2];
$output['file'] = $matches[1];
$output['extension'] = $matches[3];
}
Reference: http://www.php.net/preg_match
--
File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot
[Back to original message]
|