Jump to content

[SOLVED] strip chars from a file name


steveh62

Recommended Posts

oh yeah...lol...try this:

<?php
$imagename = 'this is a +bad file.name.jpg';
$filename = substr($imagename,0,strrpos($imagename,'.'));
$ext = substr($imagename,strrpos($imagename,'.'));
$imagename = preg_replace('/[^\w]/','_',$filename).$ext;
print $imagename;
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.