cut array from a specific character
I have this in $array[0]:
attack-responses.rules?rev=1.35&content-type=text/vnd.viewcvs-markup
开发者_StackOverflow中文版
I want to have this in $array[0]
attack-responses.rules
I mean when it will see '?' it must cut it.
Is there any PHP function?
parse_url()
$array[0] = parse_url($array[0], PHP_URL_PATH);
or list()
/explode()
list($array[0]) = explode('?', $array[0], 2);
or substr()
/strpos()
$array[0] = substr($array[0], 0, strpos($array[0], '?'))
look there at the documentation of parse_url
$str="attack-responses.rules?rev=1.35&content-type=text/vnd.viewcvs-markup";
$url=parse_url($str));
$array[0]=$url['path'];
精彩评论