gouki
注册会员

一般会员
UID 15556
精华
0
积分 114
帖子 99
金钱 114 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2002-7-29
状态 离线
|
为文件名添加诸如_thumb这样的标记
程序中经常会遇到这种情况,当你为图片生成缩略图时,往往需要保留原来的名字,而在其中插个thumb之类的字符,例如:原文件为test.jpg,生成缩略图的文件往往是test.thumb.jpg或者test_thumb.jpg这样。怎么样往里面插这样的字符呢?
插入这样的字符有几种方法:
<?php $orig_filename = 'test.jpg'; $exp_str = '_thumb';
//first $file_ext = strRchr( $orig_filename, '.' ); $fst_file = preg_replace( "/(".$file_ext.")$/", $exp_str . $file_ext , $orig_filename );
//second $orig_info = pathinfo( $orig_filename ); $scd_file = $orig_info['filename'] . $exp_str . $orig_info['extension'];
//第三种用substr的我就不写了。。懒啊 ?> 偶尔抛抛砖,你们是怎么搞的?
|  http://www.cnitblog.com/neatstudio/
http://www.neatcn.com
飞天小肥猪的简单人生 |
|