Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
文字列に次の URL があります。
$url = 'http://local/aspx/abdl.aspx?W=192796142&ID=Mini+Buggy+1';
「W」引数を解析したいと思います。
この例では、192796142 を返します。
とを使用parse_urlしparse_strます。
parse_url
parse_str
$url = 'http://local/aspx/abdl.aspx?W=192796142&ID=Mini+Buggy+1'; parse_str(parse_url($url, PHP_URL_QUERY), $params); echo $params['W']; //192796142
PHPparse_url関数を使用します。
http://php.net/manual/en/function.parse-url.php
単純なワンライナーを探している場合は、parse_strとparse_urlを使用できます。
parse_str(parse_url($url, PHP_URL_QUERY), $out); echo $out['W'];