public static
mixed
|
#
get( array $array, string $key, mixed $defaultValue = NULL, mixed $filter = NULL )
Get value for $key in array $array. If value does not exist will return defaultValue.
Get value for $key in array $array. If value does not exist will return defaultValue.
$array = array('fruit' => 'apple', 'baz' => 'quz');
$value = Core_Array::get($array, 'fruit');
$value = Core_Array::get($array, 'foo');
$value = Core_Array::get($array, 'foo', 'bar');
Parameters
- $array
- array
- $key
- key
- $defaultValue
- default value
- $filter
- filter, e.g. 'str'|'string'|'strval', 'int'|'integer'|'intval', 'float'|'floatval', 'bool'|'boolean'|'boolval', 'trim'
Returns
mixed
|
protected static
mixed
|
#
_filter( mixed $value, mixed $filter )
Filter Value
Parameters
- $value
- $filter
- filter, e.g. 'str'|'string'|'strval', 'int'|'integer'|'intval', 'float'|'floatval', 'bool'|'boolean'|'boolval', 'trim'
Returns
mixed
|
public static
|
#
set( array & $array, mixed $key, mixed $defaultValue = NULL )
Set value $defaultValue for $key in array $array.
Set value $defaultValue for $key in array $array.
Parameters
- $array
- array
- $key
- key
- $defaultValue
value
$array = array('fruit' => 'apple');
Core_Array::set($array, 'baz', 'quz');
|
public static
mixed
|
#
getRequest( $key, $defaultValue = NULL, mixed $filter = NULL )
Get value for $key in array $_REQUEST. If value does not exist will return defaultValue.
Get value for $key in array $_REQUEST. If value does not exist will return defaultValue.
Parameters
- $key
- key
- $defaultValue
- value
- $filter
filter, e.g. 'str'|'string'|'strval', 'int'|'integer'|'intval', 'float'|'floatval', 'bool'|'boolean'|'boolval', 'trim'
$value = Core_Array::getRequest('foo');
$value = Core_Array::getRequest('foo', 'bar');
Returns
mixed
|
public static
mixed
|
#
getPost( $key, $defaultValue = NULL, mixed $filter = NULL )
Get value for $key in array $_POST. If value does not exist will return defaultValue.
Get value for $key in array $_POST. If value does not exist will return defaultValue.
Parameters
- $key
- key
- $defaultValue
- value
- $filter
filter, e.g. 'str'|'string'|'strval', 'int'|'integer'|'intval', 'float'|'floatval', 'bool'|'boolean'|'boolval', 'trim'
$value = Core_Array::getPost('foo');
$value = Core_Array::getPost('foo', 'bar');
$value = Core_Array::getPost('foo', 'bar', 'trim');
Returns
mixed
|
public static
mixed
|
#
getGet( string $key, mixed $defaultValue = NULL, mixed $filter = NULL )
Get value for $key in array $_GET. If value does not exist will return defaultValue.
Get value for $key in array $_GET. If value does not exist will return defaultValue.
$value = Core_Array::getGet('foo');
$value = Core_Array::getGet('foo', 'bar');
Parameters
- $key
- key
- $defaultValue
- default value
- $filter
- filter, e.g. 'str'|'string'|'strval', 'int'|'integer'|'intval', 'float'|'floatval', 'bool'|'boolean'|'boolval', 'trim'
Returns
mixed
|
public static
mixed
|
#
getCookie( string $key, mixed $defaultValue = NULL, mixed $filter = NULL )
Get value for $key in array $_COOKIE. If value does not exist will return defaultValue.
Get value for $key in array $_COOKIE. If value does not exist will return defaultValue.
$value = Core_Array::getCookie('foo');
$value = Core_Array::getCookie('foo', 'bar');
Parameters
- $key
- key
- $defaultValue
- default value
- $filter
- filter, e.g. 'str'|'string'|'strval', 'int'|'integer'|'intval', 'float'|'floatval', 'bool'|'boolean'|'boolval', 'trim'
Returns
mixed
|
public static
mixed
|
#
getSession( string $key, mixed $defaultValue = NULL, mixed $filter = NULL )
Get value for $key in array $_SESSION. If value does not exist will return defaultValue.
Get value for $key in array $_SESSION. If value does not exist will return defaultValue.
$value = Core_Array::getSession('foo');
$value = Core_Array::getSession('foo', 'bar');
Parameters
- $key
- key
- $defaultValue
- default value
- $filter
- filter, e.g. 'str'|'string'|'strval', 'int'|'integer'|'intval', 'float'|'floatval', 'bool'|'boolean'|'boolval', 'trim'
Returns
mixed
|
public static
mixed
|
#
getFiles( $key, $defaultValue = NULL )
Get value for $key in array $_FILES. If value does not exist will return defaultValue.
Get value for $key in array $_FILES. If value does not exist will return defaultValue.
Parameters
- $key
- key
- $defaultValue
value
$value = Core_Array::getFiles('foo');
$value = Core_Array::getFiles('foo', array());
Returns
mixed
|
public static
mixed
|
#
toInt( $array )
Convert all values of array to int
Convert all values of array to int
Parameters
- $array
$array = (1, 2, '3', 'a' => '321')
$array = Core_Array::toInt($array);
var_dump($array);
Returns
mixed
|
public static
array
|
#
union( mixed $array1, array $array2 )
Union arrays $array1 and $array2. If $array1 is not array will return $array2
Union arrays $array1 and $array2. If $array1 is not array will return $array2
Parameters
Returns
array
|
public static
array
|
#
randomShuffle( array $array, integer $hash = NULL )
Перемешивание элементов массива. Если передан hash - перемешивание будет осуществлено в соответствии с этим значением.
Перемешивание элементов массива. Если передан hash - перемешивание будет осуществлено в соответствии с этим значением.
Parameters
- $array
- массив
- $hash
числовое значение
<?php
$array = array('field1', 'field2', 'field3');
$hash = 10;
$aNew = Core_Array::randomShuffle($array, $hash);
print_r($aNew);
?>
Returns
array перемешанный массив
|
public static
mixed
|
#
end( array $array )
Get the value of the last element
Get the value of the last element
Parameters
- $array
массив
<?php
$array = array('field1', 'field2', 'field3');
$lastItem = Core_Array::end($array);
var_dump($lastItem);
?>
Returns
mixed
|
public static
mixed
|
#
first( array $array )
Get the value of the first element
Get the value of the first element
Parameters
- $array
массив
<?php
$array = array('field1', 'field2', 'field3');
$firstItem = Core_Array::first($array);
var_dump($firstItem);
?>
Returns
mixed
|
public static
array
|
#
combine( array $aArray, integer $_iIndex = 0 )
Combine Arrays
Parameters
- $aArray
- $_iIndex
index
<?php
$arrays = array(
0 => array('aaa', 'bbb', 'ccc'),
22 => array(111, 222, 333)
);
$aReturn = Core_Array::combine($arrays);
print_r($aReturn);
?>
Returns
array
|
public static
string
|
#
implode( string $glue, array $array )
Join multi-level array elements with a string
Join multi-level array elements with a string
Parameters
- $glue
- $array
- The array of strings to implode.
Returns
string
|
public static
string
|
#
array2jsObject( array $array )
Convert array to the literal notation for the JS-object, e.g. array('foo' => 'bar', 'baz' => true) to string 'foo': 'bar', 'baz': true
Convert array to the literal notation for the JS-object, e.g. array('foo' => 'bar', 'baz' => true) to string 'foo': 'bar', 'baz': true
Parameters
- $array
- The array of strings to implode.
Returns
string
|