remove ban issue

everest

Member
Aug 30, 2016
1
1
35
i want to remove specyfic ban but it doesnt work https://hastebin.com/mokedinaku.php
any ideas?

Code:
function getGroups($groupsID, $getsgroups){
    foreach($groupsID as $group){
        if(in_array($group, $getsgroups)){
            $found = $group;
        }
    }
    return $found;
}
PHP Notice: Undefined variable: found

why it returns error? someone can help me with it too?
 

kalle

high minded
Contributor
Oct 28, 2015
411
253
178
Code:
function getGroups($groupsID, $getsgroups){
    foreach($groupsID as $group){
        if(in_array($group, $getsgroups)){
            $found = $group;
        }
    }
    return $found;
}
PHP Notice: Undefined variable: found

why it returns error? someone can help me with it too?
You dont define $found before. Try like this. (I edited script a little bit to make it working)

PHP:
<?php

$groupsID = array('1','2','3');
$getsgroups = array('1','3');

function getGroups($groupsID, $getsgroups){

    $found = array();

    foreach($groupsID as $group){
        if(in_array($group, $getsgroups)){
            
            $found[] = $group;
        }
    }
    return $found;
}

var_dump(getGroups($groupsID, $getsgroups));

?>
 

FarisDev

L oryh brx
Contributor
Jun 9, 2016
277
111
107
You dont define $found before. Try like this. (I edited script a little bit to make it working)

PHP:
<?php

$groupsID = array('1','2','3');
$getsgroups = array('1','3');

function getGroups($groupsID, $getsgroups){

    $found = array();

    foreach($groupsID as $group){
        if(in_array($group, $getsgroups)){
           
            $found[] = $group;
        }
    }
    return $found;
}

var_dump(getGroups($groupsID, $getsgroups));

?>

I think you can do this, without creating custom function... Using Array intersect function!

EXAMPLE:
$array1 = array(2, 4, 6, 8, 10, 12);
$array2 = array(1, 2, 3, 4, 5, 6);

var_dump(array_intersect($array1, $array2));

RETURNS:
array(3) {
[0]=> int(2)
[1]=> int(4)
[2]=> int(6)
}

HOW:

As you can see the first array contains 2, last array contains 2

So it's return 2 because they find it in the array 2.. ^^
 
Top