Files
geodb/geoapi/utility/ArrayManager.php
2013-06-27 10:55:07 +02:00

61 lines
1.4 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 . $value . $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 (!ctype_digit($value) || PHP_INT_MAX < $value) {
return FALSE;
}
}
return TRUE;
}
}
?>