add pss #62
This commit is contained in:
58
geoapi/utility/ArrayManager.php
Normal file
58
geoapi/utility/ArrayManager.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?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
|
||||
* @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 a pidList to a where-string
|
||||
* @param array $pidList
|
||||
* @return string
|
||||
*/
|
||||
public static function toSqlWhereString($array, $operator = "", $fieldname = "") {
|
||||
$arrayStr = StringManager::$emptyString;
|
||||
foreach ($array as $value) {
|
||||
$arrayStr .= $fieldname . $value . $operator;
|
||||
}
|
||||
$result = substr($arrayStr, 0, strlen($arrayStr) - strlen($operator));
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method check if all items of the pidlist are only digits
|
||||
* @param array $poly
|
||||
* @return boolean
|
||||
*/
|
||||
public static function validIntList($list) {
|
||||
foreach ($list as $value) {
|
||||
|
||||
if (!ctype_digit($value) || PHP_INT_MAX < $value) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user