2 回答

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超6個(gè)贊
這看起來(lái)像一個(gè)普通的字符串操作:
拆分字符串
獲取所需的元素
也許像這樣:
$s = '/documentLibrary/work/marketingProcess/BusinessMarketing/Design/Images/02_Product_Images/04_SHORT-RANGE/NINA/01_NINA-B1/source_WEB';
$a = explode(DIRECTORY_SEPARATOR, dirname($s)); //removes source_WEB and splits the string
echo array_pop($a); //gets the last element '01_NINA-B1'

TA貢獻(xiàn)1806條經(jīng)驗(yàn) 獲得超8個(gè)贊
這是吸血鬼嗎?從我的研究中,我發(fā)現(xiàn)db_select是一種口水功能。
你能試試這個(gè)嗎?它將嘗試分解路徑字符串并找到倒數(shù)第二個(gè)元素,如果未找到,它將返回“N / A”
$query = db_select('network_drive','networkd');
$query
->fields('networkd', array('path'))
->condition('ndid',$networkdriveid,'=')
->orderBy('networkd.ndid');
$results = $query->execute();
foreach($results as $result){
$array = explode("\\", $result->path);
echo isset($array[count($array) - 2]) ? $array[count($array) - 2] : "N/A";
}
- 2 回答
- 0 關(guān)注
- 107 瀏覽
添加回答
舉報(bào)