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