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.
我正在寻找从字符串中获取子字符串:解释这一点的最佳方法是使用以下示例:
$string = 'locations?city=London'; if (strpos($string,'city=') !== false) { // now here I need something to get London in a string }
parse_str( parse_url( 'locations?city=London', PHP_URL_QUERY ), $params ); print_r( $params ); // outputs: Array ( [city] => London ) echo $params['city']; // outputs London