PHP Class luya\helpers\ArrayHelper

Author: nadar
Inheritance: extends yii\helpers\BaseArrayHelper
ファイルを表示 Open project: zephir/luya Class Usage Examples

Public Methods

Method Description
arrayUnshiftAssoc ( array &$arr, string $key, mixed $val ) : array Prepend an assoc array item as first entry for a given array.
search ( array $array, string $searchText, boolean $sensitive = false ) : array Search trough all keys inside of an array, any occurence will return the rest of the array.
toObject ( array $array ) : object Create an object from an array.
typeCast ( array $array ) : array TypeCast values from a mixed array source. numeric values will be casted as integer.

Method Details

arrayUnshiftAssoc() public static method

Prepend an assoc array item as first entry for a given array.
public static arrayUnshiftAssoc ( array &$arr, string $key, mixed $val ) : array
$arr array The array where the value should be prepend
$key string The new array key
$val mixed The value for the new key
return array

toObject() public static method

Create an object from an array.
public static toObject ( array $array ) : object
$array array
return object

typeCast() public static method

This method is often used to convert corect json respons arrays
public static typeCast ( array $array ) : array
$array array The array which should be type casted
return array An array with type casted values