Codice PHP:
$str 'testo testo altro testo# continua';
$char  '#';
echo 
substr($str,0,strpos($str$char)-1);