十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
classid是不是?classid=xxx这样的形式?
成都创新互联坚持“要么做到,要么别承诺”的工作理念,服务领域包括:做网站、网站设计、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的潜山网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!
你所谓的网站栏目的ID号?
我的理解是这样的,那么通过$_GET["classid"]可以获得“网站栏目的ID”
假设你这个表是 table ,数据在 column 栏中
// 连接数据库操作,设变量为$connect
$query = mysql_query("SELECT column FROM table", $connect);
$value = mysql_result($query);
$array = explode(",", $value);
$classid = $_GET["classid"];
if ( !in_array($classid, $array) ) {
exit("失败");
} else {
//执行的语句
}
如果我理解的正确..好吧,这玩意儿真不难。没必要加这么多分
str_split函数能实现你这样的功能,把字符串按长度分割为数组,例如:
?php
$str = "Hello Friend";
$arr1 = str_split($str);
$arr2 = str_split($str, 3);
print_r($arr1);
print_r($arr2);
?
代码输出的结果如下:
Array
(
[0] = H
[1] = e
[2] = l
[3] = l
[4] = o
[5] =
[6] = F
[7] = r
[8] = i
[9] = e
[10] = n
[11] = d
)
Array
(
[0] = Hel
[1] = lo
[2] = Fri
[3] = end
)
?php$data = array("4,0,9#1_1", "4,5,5#1_1","4,5,1#1_1", "7,2,4#1_1", "4,4,3#1_1", "8,8,0#2_1","2,2,9#2_1","0,0,6#2_1", "0,0,7#2_1","3,3,8#2_1" );$result1 = array();
$result2 = array();
foreach($data as $key=$value)
{
$str1 = '#1_1';
$str2 = '#2_1'; if(strpos($value,$str1))
{
$tmp = str_replace($str1,'',$value);
$result1[] = $tmp;
}
else if(strpos($value,$str2))
{
$tmp = str_replace($str2,'',$value);
$result2[] = $tmp;
}
}
print_r($result1);
print_r($result2);
?
结果:Array ( [0] = 4,0,9 [1] = 4,5,5 [2] = 4,5,1 [3] = 7,2,4 [4] = 4,4,3 ) Array ( [0] = 8,8,0 [1] = 2,2,9 [2] = 0,0,6 [3] = 0,0,7 [4] = 3,3,8 )楼上大哥的是对的~~