php - Order list by specific value within in list item -


i order unordered list specific value inside list items. generate list loop.

my looped list item looks this. value <?php echo $nyslutdatum; ?> 1 wish list ordered (displayed twice because 2 cases of loop conditions)

<li>     <div id="kursprogram-kurstillfalle-kurs">          <?php the_title(); ?>      </div>      <div id="kursprogram-kurstillfalle-ort">          <?php the_sub_field('ort'); ?>      </div>      <div id="kursprogram-kurstillfalle-datum">          <?php if(get_sub_field('startdatum') != '') { ?>              <?php echo $nystartdatum; ?> - <?php echo $nyslutdatum; ?>          <?php } else { ?>              <?php echo $nyslutdatum; ?>          <?php } ?>          <?php if(get_sub_field('slutdatum_2') != '') { ?>          <br />              <?php echo $nystartdatum_2; ?> - <?php echo $nyslutdatum_2; ?>          <?php } ?>      </div>      <div id="kursprogram-kurstillfalle-notis">          <?php the_sub_field('notis') ?>      </div>      <div class="clearboth" />  </li> 

if understand question correctly, use php function "usort".

the following sort $array highest lowest "sales".

$array = array(   array('sales'=> 10, 'views'=> 200),   array('sales'=> 3,  'views'=> 100),   array('sales'=> 13, 'views'=> 500) );  usort($array,function($a,$b){   if( $a['sales'] == $b['sales'] ){     return 0;   }   return ($a['sales'] > $b['sales']) ? -1 : 1; }); 

php usort


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -