Search code examples
phparrayspodio

In Podio-Globiflow, what is the workaround for function array_rand?


I'm trying to create a function to fetch one or more random entries from my array but I'm having an "illegal call" array_rand error on my flow.

Then I realized that not all PHP functions are supported through GlobiFlow, so I was hoping that there's a workaround for this one.

screenshot:

enter image description here

Here are my variables:

  • choicesval = my array
  • randum = random number from 1 - 7
  • xField = random item(s) that were chosen from my array_rand

Here's the furthest that I got:

explode(",", choicesval)[intval(randum)]

But the problem is, it returns the element from my array based on the index. For example, my randnum got a value of 3, so in my Xfield, it will return the element at index 3 and not select 3 random items from my array.

Hope I'm making any sense at all.


Solution

  • I'm not successful in correcting my error above, however, I've found a workaround to achieve the same result.

    I created a new var named limitnum = 0, then a for each loop:

    for each item:
            if limitnum <= randnum
                  choicesval = [(Ref Client) Company Name]. ", " .[(Variable) choicesval]
                  limitnum += 1;
            end if
    continue()