Yo tengo una funcion que uso siempre para hacer lo que tu deseas la llevo conigo hace ya años :P
Código PHP:
function sacar($TheStr, $sLeft, $sRight){
$pleft = strpos($TheStr, $sLeft, 0);
if ($pleft !== false){
$pright = strpos($TheStr, $sRight, $pleft + strlen($sLeft));
If ($pright !== false) {
return (substr($TheStr, $pleft + strlen($sLeft), ($pright - ($pleft + strlen($sLeft)))));
}
}
return '';
}
$texto = 'Cadenalargasinespacios####numero_de_caracteres_indeterminado(((((';
echo sacar($texto,"####","(((((");
//imprimiria numero_de_caracteres_indeterminado