$str = 'A|B||C|D'; echo substr($str,0,strpos($str, '||')); 输出:A|B 转载于:https://www.cnblogs.com/joker-one/p/10641008.html