Is there a recommended way to implement a foreach loop with the
iterator iterating over a list of known values?
For string values that won't themselves contain a comma, I could do
this:
$var(valCSV) = "string1,string2,string3,string4";
$var(valcount) = $(var(valCSV){csv.count});
$var(valindex) = 0;
while ($var($valindex) < $var($valcount)) {
$var(thisval) = $(var(valCSV){csv.param,$var(valindex)});
$var(valindex) = $var(valindex) + 1;
# more code
}
or I could use an AVP (also handy if the strings might contain a
comma):
$avp(vals) = "string4";
$avp(vals) = "string3";
$avp(vals) = "string2";
$avp(vals) = "string1";
$var(valcount) = 4;
$var(valindex) = 0;
while ($var($valindex) < $var($valcount)) {
$var(thisval) = $avp(vals);
$avp(vals) = NULL;
$var(valindex) = $var(valindex) + 1;
# more code
}
(specifically using an iterator to count through the loop in case
something else is already using that AVP - only want to delete what I
added in the first place).
Is there a perferred way, or better way than these?
Cheers,
Kingsley.
_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users