| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
|
|
#8 (permalink) |
|
Iris Folder
Join Date: Apr 2003
Location: smokey
Posts: 2,649
|
or if it was always .jpg's you could use $text = ereg_replace(".jpg", "" , $text); but then that'd replace all instances of .jpg in the filename, so not so great. Your's is better. (that'd be grays I was on about |
|
|
|
#13 (permalink) |
|
Senior Member
Join Date: Sep 2004
Posts: 149
|
How about you make it usable for all extensions? <?php function cutExt($str) { return substr($str, 0, strrpos($str, '.')); } echo cutExt('hello.ext') . '<br />' . cutExt('hello.sheep.sex') . '<br />' . cutExt('hello.gif') . '<br />' . cutExt('hello.jpg') . '<br />' . cutExt('hello.jpeg'); ?> |
|
![]() |