Location: PHPKode > scripts > IsSetAnd > IsSetAndTest.php
<?php

//Note that IsSetAnd returns the value of the array key if the test passes, 
//and it returns null if the test fails.

require_once('IsSetAnd.php');

$ar = array(
	'test' => 1,
	'test2' => "arg",
	'test3' => array(),
	'test4' => array("arg"),
	'test5' => true,
);

$methods = get_class_methods('IsSetAnd');


echo "\nClass Methods:\n";
foreach($methods as $method) {
	echo "IsSetAnd::$method\n";
}


echo "\n\nEquals Tests:\n";
var_dump(IsSetAnd::Equals($ar, "test", 2));
var_dump(IsSetAnd::Equals($ar, "test", 1));

echo "\n\nNot Empty Tests:\n";
var_dump(IsSetAnd::NotEmpty($ar, "test2"));

echo "\n\nIs Numeric Tests:\n";
var_dump(IsSetAnd::IsNumeric($ar, "test"));

echo "\n\nIs Array Tests:\n";
var_dump(IsSetAnd::IsArray($ar, "test3"));

echo "\n\nIs Filled Array Tests:\n";

var_dump(IsSetAnd::IsFilledArray($ar, "test3"));
echo "Saved static IsSetAnd::\$value is:";
var_dump(IsSetAnd::$value);

var_dump(IsSetAnd::IsFilledArray($ar, "test4"));
echo "Saved static IsSetAnd::\$value is:";
var_dump(IsSetAnd::$value);

echo "\n\nGreater Than Zero Tests:\n";
var_dump(IsSetAnd::GreaterThanZero($ar, "test"));

echo "\n\nGreater Than Tests:\n";
var_dump(IsSetAnd::GreaterThan($ar, "test", -12));

echo "\n\nLess Than Tests:\n";
var_dump(IsSetAnd::LessThan($ar, "test", 2));

echo "\n\nGreater Than Or Equal To Tests:\n";
var_dump(IsSetAnd::GreaterThanOrEqualTo($ar, "test", 2));

echo "\n\nLess Than Or Equal To Tests:\n";
var_dump(IsSetAnd::LessThanOrEqualTo($ar, "test", 2));

echo "\n\nTrue Tests:\n";
var_dump(IsSetAnd::True($ar, "test5"));

echo "\n\nFalse Tests:\n";
var_dump(IsSetAnd::False($ar, "test5"));

echo "\n\nCTYPE Tests:\n";
var_dump(IsSetAnd::IsCtypeAlnum($ar, "test2"));
var_dump(IsSetAnd::IsCtypeAlpha($ar, "test2"));
var_dump(IsSetAnd::IsCtypeCntrl($ar, "test2"));
var_dump(IsSetAnd::IsCtypeDigit($ar, "test2"));
var_dump(IsSetAnd::IsCtypeGraph($ar, "test2"));
var_dump(IsSetAnd::IsCtypeLower($ar, "test2"));
var_dump(IsSetAnd::IsCtypePrint($ar, "test2"));
var_dump(IsSetAnd::IsCtypePunct($ar, "test2"));
var_dump(IsSetAnd::IsCtypeSpace($ar, "test2"));
var_dump(IsSetAnd::IsCtypeUpper($ar, "test2"));
var_dump(IsSetAnd::IsCtypeXdigit($ar, "test2"));

echo "\n\nUser Function Tests:\n";
var_dump(IsSetAnd::UserFunctionIsTrue($ar, "test", 'is_numeric'));

echo "\n\nRegex Tests:\n";
var_dump(IsSetAnd::MatchesRegex($ar, "test", '/[0-9]/'));
var_dump(IsSetAnd::MatchesRegex($ar, "test2", '/[a-z]{1,5}/'));

?>
Return current item: IsSetAnd