Advertisement
cdsatrian

array multi 20170125001

Jan 24th, 2017
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.55 KB | None | 0 0
  1. <?php
  2. $tarif=array(
  3.     array('tarif'=>'spp','jml_cil'=>6,'mulai'=>1),
  4.     array('tarif'=>'osis','jml_cil'=>4,'mulai'=>0)
  5. );
  6. if($tarif[0]['jml_cil']>$tarif[1]['jml_cil']){
  7.     $jml_cil=$tarif[0]['jml_cil'];
  8.     $mulai=$tarif[0]['mulai'];
  9. }else{
  10.     $jml_cil=$tarif[1]['jml_cil'];
  11.     $mulai=$tarif[1]['mulai'];
  12. }
  13. $tarif_baru=array();
  14. for($i=0;$i<$jml_cil+$mulai;$i++){
  15.     $tarif_baru[$i]=array();
  16.     foreach($tarif as $t){
  17.         if($t['jml_cil']+$t['mulai']>$i && $t['mulai']<=$i) $tarif_baru[$i][]=$t['tarif'];
  18.     }
  19. }
  20. echo '<pre>';
  21. print_r($tarif);
  22. print_r($tarif_baru);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement