Ejemplo n.º 1
0
function testArrayKeyExists($testArray, $testKey, $expected)
{
    $keyExists = arrayKeyExists($testArray, $testKey);
    if ($keyExists === $expected) {
        echo "TEST PASSED" . PHP_EOL;
    } else {
        echo "TEST FAILED" . PHP_EOL;
        echo "Expected {$expected} does not match actual {$keyExists}" . PHP_EOL;
        echo "Test Key: {$testKey}" . PHP_EOL;
        echo "Test Array: " . PHP_EOL;
        print_r($testArray);
    }
}
function arrayKeyExists(array $keys, array $array)
{
    if (!array_key_exists($keys[0], $array)) {
        return false;
    } elseif (count($keys) > 1) {
        $temp = $array[$keys[0]];
        if (is_array($temp)) {
            array_shift($keys);
            return arrayKeyExists($keys, $temp);
        } else {
            return false;
        }
    }
    return true;
}
Ejemplo n.º 3
0
            $arrEmailInfo[$i]["check"] = "checked";
        }
    }
    /*
    		else if(count($arrEmails) > 0){ //No session
    			if(!arrayKeyExists($emailInfo -> MemberName,$arrEmails)) 
    				$arrEmailInfo[$i]["check"] = "checked";				
    		}*/
    //else //There email has not sent to anybody yet.
    //$arrEmailInfo[$i]["check"] = "checked";
    $sent = "<font color=\"#0000FF\"><strong>Sent</strong></font>";
    $notsent = "<font color=\"#FF0000\"><strong>Not sent</strong></font>";
    //Evaluate the email status
    if (count($arrEmails) > 0) {
        //Some emails has been sent
        if (arrayKeyExists($emailInfo->MemberName, $arrEmails)) {
            $arrEmailInfo[$i]["status"] = $sent;
        } else {
            $arrEmailInfo[$i]["status"] = $notsent;
        }
    } else {
        //No emails has been sent out
        $arrEmailInfo[$i]["status"] = $notsent;
    }
}
//end of record set loop
//Reset the array
reset($arrEmailInfo);
if ($_GET["sort"] == 7) {
    //Arrary is to be sort by "status" ascending
    asort($arrEmailInfo);
Ejemplo n.º 4
0
            $arrEmailInfo[$i]["check"] = "checked";
        }
    }
    /*
    		else if(count($arrEmails) > 0){ //No session
    			if(!arrayKeyExists($emailInfo -> MemberName,$arrEmails)) 
    				$arrEmailInfo[$i]["check"] = "checked";				
    		}*/
    //else //There email has not sent to anybody yet.
    //$arrEmailInfo[$i]["check"] = "checked";
    $sent = "<font color=\"#0000FF\"><strong>Sent</strong></font>";
    $notsent = "<font color=\"#FF0000\"><strong>Not sent</strong></font>";
    //Evaluate the email status
    if (count($arrEmails) > 0) {
        //Some emails has been sent
        if (arrayKeyExists($emailInfo->PaperID, $arrEmails)) {
            $arrEmailInfo[$i]["status"] = $sent;
        } else {
            $arrEmailInfo[$i]["status"] = $notsent;
        }
    } else {
        //No emails has been sent out
        $arrEmailInfo[$i]["status"] = $notsent;
    }
}
//end of record set loop
//Reset the array
reset($arrEmailInfo);
if ($_GET["sort"] == 11) {
    //Array is to be sort by "status" ascending
    asort($arrEmailInfo);
Ejemplo n.º 5
0
function arrayIntersectAssoc($array1, $array2)
{
    $returnArray = array();
    foreach ($array1 as $key => $val) {
        if (arrayKeyExists($key, $array2) and (string) $array2[$key] === (string) $val) {
            $returnArray[$key] = $val;
        }
    }
    return $returnArray;
}
Ejemplo n.º 6
0
function arrayKeyExists($needle, $haystack)
{
    $result = array_key_exists($needle, $haystack);
    if ($result) {
        return $result;
    }
    foreach ($haystack as $v) {
        if (is_array($v)) {
            $result = arrayKeyExists($needle, $v);
        }
        if ($result) {
            return $result;
        }
    }
    return $result;
}