unset($n[$count($n)-1]);
should be
unset($n[count($n)-1]);
you also have two ;'s on the following line
also if there are no spaces then this will only return '...'
if(count($n)>1) unset($n[count($n)-1]);