Yet another php ereg fix
- by casben79
I have a small chunk of coding I need to take from ereg to preg_match. Here is the code.
function be_file_list($d, $x) {
foreach (array_diff(scandir($d), array('.', '..')) as $f) {
if (is_file($d . '/' . $f) && (($x) ? ereg($x.'$',$f) : 1)) {
$l[] = $f;
}
}
return $l;
}
This code works as expected even if it doesn't look too pretty
(source: http://www.php.net/manual/en/function.scandir.php)
but as ereg is deprecated, I would really like to make it preg_match, or something like that.
I have been messing with this all afternoon and the PC is about to go out the window. I would have thought that
preg_match("/"$x.'$',$f"/")
would have worked but no dice.
Any help would be great.
Cheers
Ben