Hi Guys,

Hope all are well?

sorry to post but Im just trying to get something working where Im trying to convert a php function script into the kamailio.cfg.

Im getting there but wonder how I can group results of sets of avps with another avp.

Say I have these variables;

$(avp(NTgrp)) = 'SB100_000361@1.2.3.4|SB100_000213@1.2.3.5|SB100_000225@1.2.3.6|SB100_000361@1.2.3.7|SB100_000213@1.2.3.8';
$(avp(Prio)) = '1|1|1|2|2';
$(avp(Wgt)) = '10000|10000|80000|30000|70000';
$(avp(CInc)) = '0|0|1|0|1';
$(avp(WTot))= '100000|100000|100000|100000|100000';
 
I then run a while script to split up their variables via the delimiter | in user;

$var(j)=0;
while($var(j)<$var(count)) {
$(avp(NTgrpP))=$(avp(NTgrp){s.select,$var(j),|});
$(avp(PrioP))=$(avp(Prio){s.select,$var(j),|});
$(avp(WgtP))=$(avp(Wgt){s.select,$var(j),|});
$(avp(CIncP))=$(avp(CInc){s.select,$var(j),|});
$(avp(WTotP))=$(avp(WTot){s.select,$var(j),|});
xlog("L_INFO"," Now Each time we have $(avp(NTgrpP)) $(avp(PrioP)) $(avp(WgtP)) $(avp(CIncP)) $(avp(WTotP))\n");
$var(j)=$var(j)+1;
}

This then results in;
INFO: <script>:  Now Each time we have SB100_000223@1.2.3.4 1 10000 0 100000
INFO: <script>:  Now Each time we have SB100_000225@1.2.3.5 1 10000 0 100000
INFO: <script>:  Now Each time we have SB100_000386@1.2.3.6 1 80000 0 100000
INFO: <script>:  Now Each time we have SB100_000213@1.2.3.7 2 30000 0 100000
INFO: <script>:  Now Each time we have SB100_000361@1.2.3.8 2 70000 0 100000

Now what Id like to do is group them via priorities so I can do some further functional checks on them when in same priority group, as you can see there are 3 results at priority 1 and 2 at priority 2.

Is there away I can create something of a multi-array using the AVP $(avp(PrioP)) I just created so I can group by priority?

As in php I would do something like;

$multi_arr[$prio_arr[$p]][] = array(
      "ntgrp" => $ntgrp_arr[$p],
      "prio"  => $prio_arr[$p],
      "wght"  => $wght_arr[$p],
      "cinc"  => $cinc_arr[$p],
      "wtot"  => $wtot_arr[$p],
    );
  }

Any help would be great.

Many thanks

Jon