php - Directory list into associative array -
possible duplicate:
php split string integer element , string
i have directory these files
filea10.txt fileb20.txt filec5.txt
i need read list array:
filea => 10 fileb => 20 filec => 5
what fastest way or function this?
$arr = array(); foreach (glob('*.txt') $file) { list($name,$num) = preg_split('/\.|(?<=\d)(?=\d+)/', $file); $arr[$name] = $num; }
Comments
Post a Comment