开发者

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'];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜