string '/home/adam/Projects/red/storage/22ff0bc0662bd323891844f6ed342cce2603490ec0_tumb_2.jpg' (length=85)
什么,我需要的只是 http://localhost/storage/22ff0bc0662bd323891844f6ed342cce2603490ec0_tumb_2.jpg替换字符串的最佳方法是什么?
是什么做的最好方法是什么?我的意思是使用strlen? substr_replace? substr?即时通讯有点困惑什么是最好的方式做到这一点?因为有很多方法可以做到这一点。
编辑*没有新手标签:
// get from database red/storage/22ff0bc0662bd323891844f6ed342cce2603490ec0_tumb_2.jpg
$image_path = $this->data['products'][0]['image_small'];
$exploded = end(explode('/', $image_path));
$myurl = DOMAIN;
$myfullurl = $myurl."/storage/".$exploded;
//它的工作原理!但让看到的评论也许有更好的方法:)
@sarfraz,没有我无法再使用它:|即使最好的做法也没有了,奇怪吗?也许他们正在降低数据库读取负载或其他东西。 – 2010-08-12 17:34:30