php: remove

,

,
and
from beginning and end of string

请求翻译

help...

$chars = " \t\n\r\0\x0B";
$pattern = '('.implode('|',array_map('preg_quote',array('

','

','
','
'))).')'."\b"; $data = trim(preg_replace('~'.$pattern.'$~i','',preg_replace('~^'.$pattern.'~i','',trim($data,$chars))),$chars);

That code is set to remove all

,

,
and
from the beginning and end of a html string. But it is no working quite alright. Any ideas?

1个回答