index.php?option=com_virtuemart&Itemid=210&category_id=12&lang=is&limit=20&limitstart=180&page=shop.browse
Run Code Online (Sandbox Code Playgroud)
我想从字符串中检索Page参数,如果该页面参数等于" shop.browse "而不是返回一个真的布尔值.
编辑:ps.字符串并不总是这样,但它总是包含page =参数
我一直在搞乱strpos功能和其他人,我不能让这个工作,我需要快速的代码,所以如果有人能指出我在最佳方法的正确方向.
谢谢
parse_url首先使用获取查询部分,然后使用parse_str获取值:
$query = parse_url($str,PHP_URL_QUERY);
parse_str($query, $match);
if ($match['page'] === 'shop.browse') {
// page=shop.browse
}
Run Code Online (Sandbox Code Playgroud)
请注意,这假设您的字符串存储在变量中$str.