php获取url里指定位置的参数解决办法

WBOY
Release: 2016-06-13 12:18:29
Original
1100 people have browsed it

php获取url里指定位置的参数
php获取url里指定位置的参数,因为url后的参数是变动的。怎样获取呢?如www.xxx.com?act=game&st=play&b1=1&round=1,有时候这个url会输出成www.xxx.com?act=game&st=play&b2=2&round=1,其中的b1、b2、b3.。。。一直到b15.怎样获取这个url输出的b1还是b2还是其他及他的值呢
------解决思路----------------------
把查询字符串输出成一个数组不就行了
------解决思路----------------------
用名字访问

$s = 'www.xxx.com?act=game&st=play&b1=1&round=1';<br /><br />parse_str(@array_pop(explode('?', $s)), $a);<br />print_r($a);<br /><br />$s = 'www.xxx.com?act=game&st=play&b2=2&round=1';<br /><br />parse_str(@array_pop(explode('?', $s)), $a);<br />print_r($a);
Copy after login
Array
(
    [act] => game
    [st] => play
    [b1] => 1
    [round] => 1
)
Array
(
    [act] => game
    [st] => play
    [b2] => 2
    [round] => 1
)

------解决思路----------------------
parse_str
http://www.w3school.com.cn/php/func_string_parse_str.asp

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template