经典分类筛选
Classification filter
url.php
<?php header('Content-Type:text/html;charset=utf-8'); /** * 生成分类信息中的筛选菜单 * @param $field 字段名称 * @param $modelid 模型ID * @param $diyarr 数据包 * @param $isall 是否显示全部 */ function info_filters($field = '',$diyarr = array(),$groups=array(),$isall = 1) { $options = $diyarr; $field_value = isset($_GET[$field])?intval($_GET[$field]):''; foreach($options as $k=>$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 ? '<a href="#" class="hover">'.$v.'</a>' : '<a href="'.$option[$k]['url'].'">'.$v.'</a>'; } if ($isall) { $all['name'] = '全部'; $all['url'] = info_filters_url($field,array($field=>''),$groups); $all['menu'] = $field_value == '' ? '<a href="#" class="hover">'.$all['name'].'</a>' : '<a href="'.$all['url'].'">'.$all['name'].'</a>'; 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; } ?> <style> a{ color:#333333;} .hover{ color:#FF0000;} </style> <div class="yk_01 fix"> <div class="yy1"> <?php $groups = array( 'dest'=>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 '<span>出发城市:</sapn>'; foreach($dest_list as $val){ echo $val['menu'].' '; } echo '<br/><span>目标城市:</sapn>'; foreach($action_list as $val){ echo $val['menu'].' '; } ?> </div> </div>
Copy after login
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

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article
Assassin's Creed Shadows: Seashell Riddle Solution
1 months ago
By DDD
What's New in Windows 11 KB5054979 & How to Fix Update Issues
3 weeks ago
By DDD
Where to find the Crane Control Keycard in Atomfall
1 months ago
By DDD
How to fix KB5055523 fails to install in Windows 11?
2 weeks ago
By DDD
InZoi: How To Apply To School And University
3 weeks ago
By DDD

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)
