在功能上数组值 [英] Array values in function

查看:126
本文介绍了在功能上数组值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个数组的位置:

Array
(
    [0] => Securitygroep
    [1] => Hoofdgroep
    [2] => Belangrijke Groep
    [3] => Testgroep2
    [4] => Beheergroep
    [5] => Mailgroep
    [6] => Domeingebruikers
    [7] => Gebruikers
)

我怎样才能在这个函数从数组中的所有值?

How can I get all the values from the array in this function?

$check = $adldap->group()->info("//value from array");

或者我有一种循环的方法来执行此功能?

Or do I have to execute this function in a sort of looping method?

这样的:

$check = $adldap->group()->info("Securitygroep");
$check = $adldap->group()->info("Hoofdgroep");
$check = $adldap->group()->info("Belangrijke Groep");

等等...

推荐答案

好,这取决于是什么信息()方法做。虽然你没有提供我们这样的信息,我们不能给你最准确的答案。

Well, it depends on what the info() method is doing. While you do not provide us such information, we are not able to give you the most accurate answer.

例如,如果信息方法接受数组:

For example, if info method accepts array:

public function info(array $infos) {
    foreach ($infos as $info) {
        // do smth with each element
    }
}

您可以在阵列传递直奔功能:

you can pass the array straight to the function:

$check = $adldap->group()->info($array);

如果该方法只接受一个元素,那么你通过数组需要循环,并传递给方法:

if the method accepts only one element, then you need to loop through the array and pass to the method:

foreach ($array as $value) {
    $check = $adldap->group()->info($value);
}

如果该方法接受了很多值中的一次,即逗号分隔,可以爆阵

If the method accepts a lot of values at once, i.e. comma separated, you can implode the array

 $check = $adldap->group()->info(implode(',' ,$array));

这篇关于在功能上数组值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆