在Podio-Globiflow中,函数array_rand的解决方法是什么?

时间:2018-07-13 13:49:48

标签: php arrays podio

我正在尝试创建一个函数来从我的数组中获取一个或多个随机条目,但是我的流程出现“非法调用” array_rand错误。

然后我意识到GlobiFlow并不支持所有的PHP函数,所以我希望有一种解决方法。

屏幕截图:

enter image description here

这是我的变量:

  • choicesval =我的数组
  • randum = 1-7中的随机数
  • xField =从我的array_rand
  • 中选择的随机项目

这是我得到的最远的

export function getLocation(){
    coords = {};
    navigator.geolocation.getCurrentPosition(
        (position) => {
            coords['lat'] = position.coords.latitude
            coords['long'] = position.coords.longitude
        },
        (error) => this.setState({ navigatorError: error.message }),
        { enableHighAccuracy: true, timeout: 20000, maximumAge: 1000 },
    );
    return coords;
}

但是问题是,它基于索引从我的数组返回了元素。例如,我的randnum的值为3,因此在我的Xfield中,它将返回索引3的元素,而不从我的数组中选择3个随机项。

希望我完全没有道理。

1 个答案:

答案 0 :(得分:0)

我无法成功纠正上述错误,但是,我找到了一种解决方法来达到相同的结果。

我创建了一个名为limitnum = 0的新var,然后为每个循环创建了一个:

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