- url.php
- $v) {$option[$k]['name'] = $v;
- $option[$k]['value'] = $k;
- $option[$k]['url'] = info_filters_url($field,array($field=>$k),$groups);
- $option[$k]['menu'] = $field_value == $k ? ''.$v.'' : ''.$v.'';
- }
- if ($isall) {
- $all['name'] = '全部';
- $all['url'] = info_filters_url($field,array($field=>''),$groups);
- $all['menu'] = $field_value == ''?''.$all['name'].'':''.$all['name'].'';
- array_unshift($option,$all);
- }
- return $option;
- }
- /**
- * 构造筛选 URL
- */
- function info_filters_url($fieldname, $array=array(),$fields=array(), $isphp = 0) {
- if(empty($array)) {
- $array = $_GET;
- } else {
- $array = array_merge($_GET,$array);
- }
- //TODO
- if(is_array($fields) && !empty($fields)) {
- ksort($fields);
- $urlpars ='';
- foreach ($fields as $_v=>$_k) {
- $urlpars .= '&'.$_v.'={$'.$_v.'}';
- }
- }
- $urlrule ='urlurl.php?m=content&c=index&a=lists&catid=1'.$urlpars;
- // 根据 get 传值构造 URL
- if (is_array($array)) foreach ($array as $_k=>$_v) {
- if($_k=='page') $_v=1;
- $_findme[] = '/{\$'.$_k.'}/';
- $_v = intval($_v);
- $_replaceme[] = $_v;
- }
- // 构造排除该字段名称的正则
- $filter = '';
- $_findme[] = '/{\$'.$filter.'([a-z0-9_]+)}/';
- $_replaceme[] = '';
- $urlrule = preg_replace($_findme, $_replaceme, $urlrule);
- return $urlrule;
- }
- ?>
- array(1=>'北京',2=>'上海',3=>'天津'),
- 'action'=>array(1=>'香港',2=>'澳门',3=>'台湾')
- );
- $dest_list = info_filters('dest',$groups['dest'],$groups);
- $action_list = info_filters('action',$groups['action'],$groups);
- echo '出发城市:';
- foreach($dest_list as $val){
- echo $val['menu'].' ';
- }
- echo '目标城市:';
- foreach($action_list as $val){
- echo $val['menu'].' ';
- }
- ?>
来源: https://www.php1.cn/detail/php-243dd17abd.html