Hi,
I have to iterate string like 1,2,3,4 in kamailio. How could you do this? I know we have s.select,index,separator but I dont know how to go through all elements. Thanks,
Mino
Mino,
Something like this should probably work:
$var(x) = "1,2,3,4";
$var(i) = 0;
while(defined $(var(x){s.select,$var(i),,})) { ...
$var(i) = $var(i) + 1; }
If the 'defined' operator always results 'true' on the results of this transformation, then alternately this:
while($(var(x){s.select,$var(i),,}{s.len}) > 0)
-- Alex
On 6/11/13 3:54 PM, Alex Balashov wrote:
Mino,
Something like this should probably work:
$var(x) = "1,2,3,4";
$var(i) = 0;
while(defined $(var(x){s.select,$var(i),,})) { ...
$var(i) = $var(i) + 1;
}
If the 'defined' operator always results 'true' on the results of this transformation, then alternately this:
while($(var(x){s.select,$var(i),,}{s.len}) > 0)
It should work testing if result is !=$null as well, I added an entry in faq, anyone could jump and enhance the content with other options:
https://www.kamailio.org/wiki/tutorials/faq/main#how_to_iterate_through_the_...
Cheers, Daniel