PHP.....Fundamental

 sorting as array of associative array.....using the value of perticular key:

In ascending order:

usort($inventory, function ($item1, $item2) {
    return $item1['price'] <=> $item2['price'];
});
In descending order 
usort($inventory, function ($item1, $item2) {
    return $item2['price'] <=> $item1['price'];
}); 
 
Other solution :
array_multisort(array_column($inventory, 'price'), SORT_DESC, $inventory);
If you want Case Insensitive Sort on strings, you can use SORT_NATURAL|SORT_FLAG_CASE
array_multisort(array_column($inventory, 'key_name'), SORT_DESC, SORT_NATURAL|SORT_FLAG_CASE, $inventory);   

count occurrences of values in an associative array in php


$employees = array(
   1 => array(
       'name' => 'Jason Alipala',
       'employee_id' => 'G1001-05',
       'position' => 1             
   ),
   2 => array(
       'name' => 'Bryann Revina',
       'employee_id' => 'G1009-03',
       'position' => 2           
   ),
   3 => array(
       'name' => 'Jeniel Mangahis',
       'employee_id' => 'G1009-04',
       'position' => 2
   ),
   4 => array(
       'name' => 'Arjay Bussala',
       'employee_id' => 'G1009-05',
       'position' => 3        
   ),
   5 => array(
       'name' => 'Ronnel Ines',
       'employee_id' => 'G1002-06',
       'position' => 3           
   )
   );
 
 
 ANSWER -
 $counts = array_count_values(
    array_column($employees, 'position')
);
 
 
 

Over Lay :

html :

<div class="overlay"></div>
<div class="spanner">
  <div class="loader"></div>
</div> 
 

CSS : 

    
.spanner{
  position:absolute;
  top: 50%;
  left: 0;
  background: #2a2a2a55;
  width: 100%;
  display:block;
  text-align:center;
  height: 300px;
  color: #FFF;
  transform: translateY(-50%);
  z-index: 1000;
  visibility: hidden;
}

.overlay{
  position: fixed;
    width: 100%;
    height: 100%;
  background: rgba(0,0,0,0.5);
  visibility: hidden;
}

.loader,
.loader:before,
.loader:after {
  border-radius: 50%;
  width: 2.5em;
  height: 2.5em;
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
  -webkit-animation: load7 1.8s infinite ease-in-out;
  animation: load7 1.8s infinite ease-in-out;
}
.loader {
  color: #ffffff;
  font-size: 10px;
  margin: 80px auto;
  position: relative;
  text-indent: -9999em;
  -webkit-transform: translateZ(0);
  -ms-transform: translateZ(0);
  transform: translateZ(0);
  -webkit-animation-delay: -0.16s;
  animation-delay: -0.16s;
}
.loader:before,
.loader:after {
  content: '';
  position: absolute;
  top: 0;
}
.loader:before {
  left: -3.5em;
  -webkit-animation-delay: -0.32s;
  animation-delay: -0.32s;
}
.loader:after {
  left: 3.5em;
}
@-webkit-keyframes load7 {
  0%,
  80%,
  100% {
    box-shadow: 0 2.5em 0 -1.3em;
  }
  40% {
    box-shadow: 0 2.5em 0 0;
  }
}
@keyframes load7 {
  0%,
  80%,
  100% {
    box-shadow: 0 2.5em 0 -1.3em;
  }
  40% {
    box-shadow: 0 2.5em 0 0;
  }
}

.show{
  visibility: visible;
}

.spanner, .overlay{
    opacity: 0;
    -webkit-transition: all 0.3s;
    -moz-transition: all 0.3s;
    transition: all 0.3s;
}

.spanner.show, .overlay.show {
    opacity: 1
}

 JS
$("div.spanner").addClass("show");
$("div.overlay").addClass("show");
 
 
 
 

Comments

Popular posts from this blog

preparation analytics

Higher package

General info - 6350958828e0b