Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $tarif=array(
- array('tarif'=>'spp','jml_cil'=>6,'mulai'=>1),
- array('tarif'=>'osis','jml_cil'=>4,'mulai'=>0)
- );
- if($tarif[0]['jml_cil']>$tarif[1]['jml_cil']){
- $jml_cil=$tarif[0]['jml_cil'];
- $mulai=$tarif[0]['mulai'];
- }else{
- $jml_cil=$tarif[1]['jml_cil'];
- $mulai=$tarif[1]['mulai'];
- }
- $tarif_baru=array();
- for($i=0;$i<$jml_cil+$mulai;$i++){
- $tarif_baru[$i]=array();
- foreach($tarif as $t){
- if($t['jml_cil']+$t['mulai']>$i && $t['mulai']<=$i) $tarif_baru[$i][]=$t['tarif'];
- }
- }
- echo '<pre>';
- print_r($tarif);
- print_r($tarif_baru);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement