75 lines
1.9 KiB
PHP
75 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace utiliy;
|
|
|
|
include_once "../../global.inc.php";
|
|
include_once PATH_UTILITTY . "/StringManager.php";
|
|
|
|
/**
|
|
* The ArrayManager provides some array-methods
|
|
* @author stubbfel
|
|
* @since 26.06.2013
|
|
*/
|
|
class ArrayManager {
|
|
|
|
/**
|
|
* Method remove all empty itmes of an array
|
|
* @param array $queryArgs
|
|
* @return array
|
|
*/
|
|
public static function removeEmptyItmes($array) {
|
|
foreach ($array as $key => $value) {
|
|
if (empty($value)) {
|
|
unset($array[$key]);
|
|
}
|
|
}
|
|
return $array;
|
|
}
|
|
|
|
/**
|
|
* Method convert an array to a where-string like $fieldname = $array[i] $operator
|
|
* @param array $pidList
|
|
* @return string
|
|
*/
|
|
public static function toSqlWhereString($array, $operator = "", $fieldname = "") {
|
|
$arrayStr = StringManager::$emptyString;
|
|
foreach ($array as $value) {
|
|
$arrayStr .= $fieldname . StringManager::$quotes . $value . StringManager::$quotes . $operator;
|
|
}
|
|
$result = substr($arrayStr, 0, strlen($arrayStr) - strlen($operator));
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* Method check if all items of the array are only digits and < PHP_INT_MAX
|
|
* @param array $poly
|
|
* @return boolean
|
|
*/
|
|
public static function validIntList($list) {
|
|
foreach ($list as $value) {
|
|
if (!StringManager::validInt($value)) {
|
|
return FALSE;
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
/**
|
|
* Method check if all items of the array are only digits and < PHP_INT_MAX
|
|
* @param array $poly
|
|
* @return boolean
|
|
*/
|
|
public static function validAlphaNumList($list) {
|
|
foreach ($list as $value) {
|
|
|
|
if (!ctype_alnum($value) || !\utiliy\StringManager::validSQLString($value)) {
|
|
return FALSE;
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
}
|
|
|
|
?>
|