小编muk*_*van的帖子

如何计算数组中重复项的出现次数

我想计算数组中每个重复项的出现次数,最后得到一个只有唯一/非重复项的数组及其各自的出现次数.

这是我的代码; 但我不会在哪里出错!

<?php
$array = array(12,43,66,21,56,43,43,78,78,100,43,43,43,21);

//$previous[value][Occurrence]

for($arr = 0; $arr < count($array); $arr++){

    $current = $array[$arr];
    for($n = 0; $n < count($previous); $n++){
        if($current != $previous[$n][0]){// 12 is not 43 -----> TRUE
            if($current != $previous[count($previous)][0]){
                $previous[$n++][0] = $current;
                $previous[$n++][1] = $counter++;
            }
        }else{  
            $previous[$n][1] = $counter++;
            unset($previous[count($previous)-1][0]);
            unset($previous[count($previous)-1][1]);
        }   
    }
}
//EXPECTED VALUES
echo 'No. of NON Duplicate Items: '.count($previous).'<br><br>';// 7
print_r($previous);// array( {12,1} , {21,2} , {43,6} , {66,1} , {56,1} , {78,2} , {100,1})
?>    
Run Code Online (Sandbox Code Playgroud)

php arrays count

44
推荐指数
4
解决办法
9万
查看次数

如何在jquery cookie中存储数组?

我需要在jQuery cookie中存储一个数组,任何人都可以帮助我吗?

arrays cookies jquery

22
推荐指数
2
解决办法
7万
查看次数

覆盖溢出:用z-index隐藏

我正在使用coda_bubble jquery插件,我需要让我的气泡在溢出隐藏的div中弹出.这是我的示例代码.

<html>
<head>
<title>Override overflow:hidden</title>
<link href="http://www.myjquery.co.uk/jslib/jquery_plugins/coda_bubble/bubble.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.0/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://www.myjquery.co.uk/jslib/jquery_plugins/coda_bubble/jquery.codabubble.js"></script>
<script type="text/javascript">
$(function(){
   opts = {
      distances : [40,40],
      leftShifts : [0,0],
      bubbleTimes : [400,400],
      hideDelays : [0,0],
      bubbleWidths : [200,200],
      bubbleImagesPath : "YOUR RELATIVE PATH TO SKIN FOLDER",
      msieFix : true
   };
   $('.coda_bubble').codaBubble(opts);
});
</script> 
<style type="text/css">
body{
    margin:0;
    padding:0;
    }
#wrapper{
    width:300px;
    margin:200px auto;
    }
.overflow{
    width:120px;
    height:80px;
    overflow:hidden;
    float:left;
    }
.coda_bubble{
    z-index:100;/****NOT WORKING*******/
    }
</style>
</head> …
Run Code Online (Sandbox Code Playgroud)

html css z-index overflow

12
推荐指数
4
解决办法
4万
查看次数

k2组件在哪里将其图像存储在数据库中?

我想检索/查询joomla k2组件存储的图像(在图像选项卡下).

joomla components joomla-k2

10
推荐指数
2
解决办法
2万
查看次数

如何打印保存CSS的div内容

我想打印div内容,同时保持css应用于div和内部html.

我使用jQuery打印元素,但它剥离了CSS.

html css printing jquery

2
推荐指数
1
解决办法
1万
查看次数

在PHP中获取日期/时间差异

我试图获得两天之间的时差.但是对于某些日期/时间,我得到了错误的答案

这是我的代码:

/****************************************
$start_date = new DateTime('23:58:40'); *These two still give 
$end_date = new DateTime('00:00:00');   *a wrong answer
*****************************************/

$start_date = new DateTime('23:58:40');
$end_date = new DateTime('00:11:36');

$dd = date_diff($end_date, $start_date);

//Giving a wrong answer: Hours = 23, Minutes = 47, Seconds = 4 
echo "Hours = $dd->h, Minutes = $dd->i, Seconds = $dd->s";
Run Code Online (Sandbox Code Playgroud)

php time date

1
推荐指数
1
解决办法
4461
查看次数

标签 统计

arrays ×2

css ×2

html ×2

jquery ×2

php ×2

components ×1

cookies ×1

count ×1

date ×1

joomla ×1

joomla-k2 ×1

overflow ×1

printing ×1

time ×1

z-index ×1