helpers\BaseArrayHelper isSubset()

isSubset() public static method (available since version 2.0.7) Checks whether an array or Traversable is a subset of another array or Traversable. This method will return true, if all elements of $needles are contained in $haystack. If at least one element is missing, false will be returned. public static boolean isSubset ( $needles, $haystack, $strict = false )$needles array|Traversable The values that must all be in $haystack. $haystack array|Traversable The set of value to sear

helpers\BaseArrayHelper isIndexed()

isIndexed() public static method Returns a value indicating whether the given array is an indexed array. An array is indexed if all its keys are integers. If $consecutive is true, then the array keys must be a consecutive sequence starting from 0. Note that an empty array will be considered indexed. public static boolean isIndexed ( $array, $consecutive = false )$array array The array being checked $consecutive boolean Whether the array keys must be a consecutive sequence in order for

helpers\BaseArrayHelper isIn()

isIn() public static method (available since version 2.0.7) Check whether an array or Traversable contains an element. This method does the same as the PHP function in_array() but additionally works for objects that implement the Traversable interface. See also http://php.net/manual/en/function.in-array.php. public static boolean isIn ( $needle, $haystack, $strict = false )$needle mixed The value to look for. $haystack array|Traversable The set of values to search. $strict boolean

helpers\BaseArrayHelper isAssociative()

isAssociative() public static method Returns a value indicating whether the given array is an associative array. An array is associative if all its keys are strings. If $allStrings is false, then an array will be treated as associative if at least one of its keys is a string. Note that an empty array will NOT be considered associative. public static boolean isAssociative ( $array, $allStrings = true )$array array The array being checked $allStrings boolean Whether the array keys must b

helpers\BaseArrayHelper index()

index() public static method Indexes and/or groups the array according to a specified key. The input should be either multidimensional array or an array of objects. The $key can be either a key name of the sub-array, a property name of object, or an anonymous function that must return the value that will be used as a key. $groups is an array of keys, that will be used to group the input array into one or more sub-arrays based on keys specified. If the $key is specified as null or a value of

helpers\BaseArrayHelper htmlEncode()

htmlEncode() public static method Encodes special characters in an array of strings into HTML entities. Only array values will be encoded by default. If a value is an array, this method will also encode it recursively. Only string values will be encoded. See also http://www.php.net/manual/en/function.htmlspecialchars.php. public static array htmlEncode ( $data, $valuesOnly = true, $charset = null )$data array Data to be encoded $valuesOnly boolean Whether to encode array values only. I

helpers\BaseArrayHelper htmlDecode()

htmlDecode() public static method Decodes HTML entities into the corresponding characters in an array of strings. Only array values will be decoded by default. If a value is an array, this method will also decode it recursively. Only string values will be decoded. See also http://www.php.net/manual/en/function.htmlspecialchars-decode.php. public static array htmlDecode ( $data, $valuesOnly = true )$data array Data to be decoded $valuesOnly boolean Whether to decode array values only. I

helpers\BaseArrayHelper getValue()

getValue() public static method Retrieves the value of an array element or object property with the given key or property name. If the key does not exist in the array or object, the default value will be returned instead. The key may be specified in a dot format to retrieve the value of a sub-array or the property of an embedded object. In particular, if the key is x.y.z, then the returned value would be $array['x']['y']['z'] or $array->x->y->z (if $array is an object). If $array['

helpers\BaseArrayHelper getColumn()

getColumn() public static method Returns the values of a specified column in an array. The input array should be multidimensional or an array of objects. For example, $array = [ ['id' => '123', 'data' => 'abc'], ['id' => '345', 'data' => 'def'], ]; $result = ArrayHelper::getColumn($array, 'id'); // the result is: ['123', '345'] // using anonymous function $result = ArrayHelper::getColumn($array, function ($element) { return $element['id']; }); public static array

helpers\BaseArrayHelper filter()

filter() public static method (available since version 2.0.9) Filters array according to rules specified. For example: $array = [ 'A' => [1, 2], 'B' => [ 'C' => 1, 'D' => 2, ], 'E' => 1, ]; $result = \yii\helpers\ArrayHelper::filter($array, ['A']); // $result will be: // [ // 'A' => [1, 2], // ] $result = \yii\helpers\ArrayHelper::filter($array, ['A', 'B.C']); // $result will be: // [ // 'A' => [1, 2], // 'B' => ['C' =>