我想计算数组中每个重复项的出现次数,最后得到一个只有唯一/非重复项的数组及其各自的出现次数.
这是我的代码; 但我不会在哪里出错!
<?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) 我需要在jQuery cookie中存储一个数组,任何人都可以帮助我吗?
我正在使用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) 我想检索/查询joomla k2组件存储的图像(在图像选项卡下).
我想打印div内容,同时保持css应用于div和内部html.
我使用jQuery打印元素,但它剥离了CSS.
我试图获得两天之间的时差.但是对于某些日期/时间,我得到了错误的答案
这是我的代码:
/****************************************
$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)