C# Class Pchp.Library.Arrays

Implements PHP array functions.
Mostrar archivo Open project: iolevel/peachpie

Public Methods

Method Description
array_change_key_case ( PhpArray array ) : PhpArray

Converts string keys in PhpArray to lower case.

Integer keys as well as all values remain unchanged.

array_change_key_case ( PhpArray array, LetterCase keyCase ) : PhpArray

Converts string keys in PhpArray to specified case.

Integer keys as well as all values remain unchanged.

array_chunk ( PhpArray array, int size, bool preserveKeys = false ) : PhpArray

Splits an array into chunks.

Chunks will contain deep copies of array items.

array_combine ( PhpArray keys, PhpArray values ) : PhpArray

Creates an array using one array for its keys and the second for its values.

keys and values should have the same length (zero is adminssible - an empty array is returned). Keys are converted using PHP.Core.Convert.ObjectToArrayKey before hashed to resulting array. If more keys has the same value after conversion the last one is used. If a key is not a legal array key it is skipped.Doesn't dereference PHP references.

array_count_values ( PhpArray array ) : PhpArray

Counts frequency of each value in an array.

Only string and int values are counted. Note, string numbers (e.g. "10") and their integer equivalents (e.g. 10) are counted separately.

array_diff ( Context ctx, PhpArray array ) : PhpArray

Computes the difference of arrays.

Keys are preserved. Entries are considered to be equal iff values compared by by string comparison method are the same (see ValueComparer.String).

array_diff_assoc ( Context ctx, PhpArray array ) : PhpArray

Computes the difference of arrays.

Keys are preserved. Entries are considered to be equal iff they has the same keys and values according to string method comparison (see EntryComparer and PhpStringComparer).

array_diff_key ( Context ctx, PhpArray array ) : PhpArray

Computes the difference of arrays.

Entries are considered to be equal iff keys compared by by string comparison method are the same (see KeyComparer.String).

array_diff_uassoc ( Context ctx, PhpArray array, PhpArray array0 ) : PhpArray

Computes the difference of arrays using a specified comparer.

array_diff_ukey ( Context ctx, PhpArray array, PhpArray array0 ) : PhpArray

Computes the difference of arrays using a specified key comparer.

array_fill ( int startIndex, int count, PhpValue value ) : PhpArray

Creates a new array filled with a specified value.

array_fill_keys ( PhpArray keys, PhpValue value ) : PhpArray
array_filter ( Context ctx, PhpArray array, IPhpCallable callback ) : PhpArray

Filters an array using a specified callback.

array_filter ( PhpArray array ) : PhpArray

Retuns the specified array. see http://php.net/manual/en/function.array-filter.php

The caller argument is here just because of the second Filter() method. Phalanger shares the function properties over the overloads.

array_flip ( PhpArray array ) : PhpArray

Swaps all keys and their associated values in an array.

Values which are not of type string nor int are skipped and for each such value a warning is reported. If there are more entries with the same value in the array the last key is considered others are ignored. String keys are converted using Core.Convert.StringToArrayKey.

Unlike PHP this method doesn't return false on failure but a null reference. This is because it fails only if array is a null reference.

array_intersect ( Context ctx, PhpArray array ) : PhpArray

Computes the intersection of arrays.

array_intersect_assoc ( Context ctx, PhpArray array ) : PhpArray

Computes the intersection of arrays.

array_intersect_key ( Context ctx, PhpArray array ) : PhpArray

Computes the intersection of arrays.

array_intersect_uassoc ( Context ctx, PhpArray array, PhpArray array0 ) : PhpArray

Computes the intersection of arrays using a specified comparer.

array_intersect_ukey ( Context ctx, PhpArray array, PhpArray array0 ) : PhpArray

Computes the intersection of arrays using a specified key comparer.

array_key_exists ( IntStringKey key, PhpArray array ) : bool

Checks if a key exists in the array.

key is converted before the search.

array_keys ( PhpArray array ) : PhpArray

Retrieves an array of keys contained in a given array.

array_keys ( PhpArray array, PhpValue searchValue, bool strict = false ) : PhpArray

Retrieves an array of some keys contained in a given array.

array_map ( Context ctx, IPhpCallable map ) : PhpArray

Applies a callback function on specified tuples one by one storing its results to an array.

In the i-th call the j-th parameter of the callback will be the i-th value of the j-the array or a null if that array has less then i entries.

If the callback assigns a value to a parameter passed by reference in the i-the call and the respective array contains at least i elements the assigned value is propagated to the array.

array_merge ( ) : PhpArray

Merges one or more arrays. Integer keys are changed to new ones, string keys are preserved. Values associated with existing string keys are be overwritten.

array_merge_recursive ( PhpArray array ) : PhpArray

Merges arrays recursively.

Integer keys are reset so there cannot be a conflict among them. Conflicts among string keys are resolved by merging associated values into arrays. Merging is propagated recursively. Merged values are dereferenced. References are preserved in non-merged values.

array_multisort ( Context ctx, [ first ) : bool

Sort multiple arrays.

Reindexes integer keys in the sorted arrays and restarts their intrinsic enumerators.

array_pad ( PhpArray array, int length, PhpValue value ) : PhpArray

Pads array to the specified length with a value. If the length is negative adds |length| elements at beginning otherwise adds elements at the end. Values with integer keys that are contained in the source array are inserted to the resulting one with new integer keys counted from zero (or from |length| if length negative).

array_pop ( PhpArray array ) : PhpValue

Removes the last item from an array and returns it.

Resets intrinsic enumerator.

array_product ( PhpArray array ) : PhpNumber

Computes a product of all values in an array. Each value is converted to a number in the same way it is done by PHP.

array_push ( PhpArray array ) : int

Adds multiple items into an array.

array_rand ( PhpArray array, int count = 1 ) : PhpValue

Chooses specified number of keys from an array at random.

Items are chosen uniformly in time O(n), where n is the number of items in the array using conveyor belt sampling.

array_reduce ( Context ctx, [ array, IPhpCallable function ) : PhpValue
array_reduce ( Context ctx, [ array, IPhpCallable function, PhpValue initialValue ) : PhpValue
array_replace ( [ array ) : PhpArray

array_replace() replaces the values of the first array with the same values from all the following arrays. If a key from the first array exists in the second array, its value will be replaced by the value from the second array. If the key exists in the second array, and not the first, it will be created in the first array. If a key only exists in the first array, it will be left as is. If several arrays are passed for replacement, they will be processed in order, the later arrays overwriting the previous values. array_replace() is not recursive : it will replace values in the first array by whatever type is in the second array.

array_replace_recursive ( [ array ) : PhpArray

array_replace_recursive() replaces the values of the first array with the same values from all the following arrays. If a key from the first array exists in the second array, its value will be replaced by the value from the second array. If the key exists in the second array, and not the first, it will be created in the first array. If a key only exists in the first array, it will be left as is. If several arrays are passed for replacement, they will be processed in order, the later array overwriting the previous values. array_replace_recursive() is recursive : it will recurse into arrays and apply the same process to the inner value. When the value in array is scalar, it will be replaced by the value in array1, may it be scalar or array. When the value in array and array1 are both arrays, array_replace_recursive() will replace their respective value recursively.

array_reverse ( PhpArray array, bool preserveKeys = false ) : PhpArray

Returns array which elements are taken from a specified one in reversed order.

array_search ( PhpValue needle, PhpArray haystack, bool strict = false ) : PhpValue

Searches the array for a given value and returns the corresponding key if successful.

array_shift ( PhpArray array ) : PhpValue

Removes the first item of an array and reindex integer keys starting from zero.

Resets intrinsic enumerator.

array_slice ( PhpArray array, int offset, int length = int.MaxValue, bool preserveKeys = false ) : PhpArray

Retrieves a slice of specified array.

See PhpMath.AbsolutizeRange for details about offset and length.

array_splice ( PhpArray array, int offset, int length = int.MaxValue ) : PhpArray

Removes a slice of an array.

length items are removed from array starting with the offset-th one.

array_splice ( PhpArray array, int offset, int length, PhpValue replacement ) : PhpArray

Replaces a slice of an array with specified item(s).

The same as Splice(PhpArray,int,int,object) except for that replacement items are deeply copied to the array.

array_sum ( PhpArray array ) : PhpNumber

Sums all values in an array. Each value is converted to a number in the same way it is done by PHP.

array_udiff ( Context ctx, PhpArray array, PhpArray array0 ) : PhpArray

Computes the difference of arrays using a specified comparer.

array_udiff_assoc ( Context ctx, PhpArray array, PhpArray array0 ) : PhpArray

Computes the difference of arrays using a specified comparer.

array_udiff_uassoc ( Context ctx, PhpArray array, PhpArray array0 ) : PhpArray

Computes the difference of arrays using specified comparers.

array_uintersect ( Context ctx, PhpArray array, PhpArray array0 ) : PhpArray

Computes the intersection of arrays using a specified comparer.

array_uintersect_assoc ( Context ctx, PhpArray array, PhpArray array0 ) : PhpArray

Computes the intersection of arrays using a specified comparer.

array_uintersect_uassoc ( Context ctx, PhpArray array, PhpArray array0 ) : PhpArray

Computes the intersection of arrays using specified comparers.

array_unique ( Context ctx, PhpArray array, ComparisonMethod sortFlags = ComparisonMethod.String ) : PhpArray

Removes duplicate values from an array.

Values are compared using string comparison method (ValueComparer.String).

array_unshift ( PhpArray array ) : int

Inserts specified items before the first item of an array and reindex integer keys starting from zero.

array_values ( PhpArray array ) : PhpArray

Retrieves an array of values contained in a given array.

Doesn't dereference PHP references.

array_walk ( Context ctx, [ array, IPhpCallable function ) : bool

Applies a user function or method on each element of a specified array or dictionary.

See Walk(PHP.Core.Reflection.DTypeDesc,PhpHashtable,PhpCallback,object) for details.

array_walk ( Context ctx, [ array, IPhpCallable callback, PhpValue data ) : bool

Applies a user function or method on each element (value) of a specified dictionary.

array_walk_recursive ( Context ctx, [ array, IPhpCallable callback ) : bool

Applies a user function or method on each element of a specified array recursively.

See Walk(PHP.Core.Reflection.DTypeDesc,PhpHashtable,PhpCallback,object) for details.

array_walk_recursive ( Context ctx, [ array, IPhpCallable callback, PhpValue data ) : bool

Applies a user function or method on each element (value) of a specified dictionary recursively.

Walk.

arsort ( Context ctx, [ array, ComparisonMethod comparisonMethod = ComparisonMethod.Regular ) : bool

Sorts an array using specified comparison method for comparing values in reverse order preserving key-value associations.

Resets array's intrinsic enumerator.

asort ( Context ctx, [ array, ComparisonMethod comparisonMethod = ComparisonMethod.Regular ) : bool

Sorts an array using specified comparison method for comparing values preserving key-value associations.

Resets array's intrinsic enumerator.

current ( IPhpEnumerable array ) : PhpValue

Retrieves a value being pointed by an array intrinsic enumerator.

The value returned is dereferenced.

each ( IPhpEnumerable array ) : PhpArray

Retrieves the current entry and advances array intrinsic enumerator one item forward.

end ( IPhpEnumerable array ) : PhpValue

Moves array intrinsic enumerator so it will point to the last item of the array.

The value returned is dereferenced.

in_array ( PhpValue needle, PhpArray haystack, bool strict = false ) : bool

Checks if a value exists in an array.

key ( IPhpEnumerable array ) : PhpValue

Retrieves a key being pointed by an array intrinsic enumerator.

key_exists ( IntStringKey key, PhpArray array ) : bool

Alias of array_key_exists.

krsort ( Context ctx, [ array, ComparisonMethod comparisonMethod = ComparisonMethod.Regular ) : bool

Sorts an array using specified comparison method for comparing keys in reverse order.

Resets array's intrinsic enumerator.

ksort ( Context ctx, [ array, ComparisonMethod comparisonMethod = ComparisonMethod.Regular ) : bool

Sorts an array using specified comparison method for comparing keys.

Resets array's intrinsic enumerator.

natcasesort ( Context ctx, [ array ) : bool

Sorts an array using case insensitive natural comparison method for comparing values preserving key-value association.

Resets array's intrinsic enumerator.

natsort ( Context ctx, [ array ) : bool

Sorts an array using case sensitive natural comparison method for comparing values preserving key-value association.

Resets array's intrinsic enumerator.

next ( IPhpEnumerable array ) : PhpValue

Advances array intrinsic enumerator one item forward.

The value returned is dereferenced.

pos ( IPhpEnumerable array ) : object

Retrieves a value being pointed by an array intrinsic enumerator.

Alias of current. The value returned is dereferenced.

prev ( IPhpEnumerable array ) : PhpValue

Moves array intrinsic enumerator one item backward.

The value returned is dereferenced.

range ( Context ctx, PhpValue low, PhpValue high ) : PhpArray

Creates an array containing range of elements with step 1.

range ( Context ctx, PhpValue low, PhpValue high, PhpValue step ) : PhpArray

Creates an array containing range of elements with arbitrary step.

Implements PHP awful range function. The result depends on types and content of parameters under the following rules: If at least one parameter (low, high or step) is of type double or is a string wholly representing double value (i.e. whole string is converted to a number and no chars remains, e.g. "1.5" is wholly representing but the value "1.5x" is not) than range of double values is generated with a step treated as a double value (e.g. range("1x","2.5x","0.5") = array(1.0, 1.5, 2.0, 2.5) etc.) otherwise if at least one bound (i.e. low or high parameter) is of type int or is a string wholly representing integer value than range of integer values is generated with a step treated as integer value (e.g. range("1x","2","1.5") = array(1, 2, 3, 4) etc.) otherwise low and high are both non-empty strings (otherwise one of the two previous conditions would be true), so the first characters of these strings are taken and a sequence of characters is generated. Moreover, if low is greater than high then descending sequence is generated and ascending one otherwise. If step is less than zero than an absolute value is used.

range ( long low, long high ) : PhpArray

Creates an array containing range of elements with step 1.

reset ( IPhpEnumerable array ) : PhpValue

Moves array intrinsic enumerator so it will point to the first item of the array.

The value returned is dereferenced.

rsort ( Context ctx, [ array, ComparisonMethod comparisonMethod = ComparisonMethod.Regular ) : bool

Sorts an array using specified comparison method for comparing values in reverse order.

Resets array's intrinsic enumerator.

shuffle ( PhpArray array ) : bool

Randomizes the order of elements in the array using PhpMath random numbers generator.

Reindexes all keys in the resulting array.

sort ( Context ctx, [ array, ComparisonMethod comparisonMethod = ComparisonMethod.Regular ) : bool

Sorts an array using specified comparison method for comparing values.

Resets array's intrinsic enumerator.

uasort ( Context ctx, [ array, IPhpCallable compare ) : bool

Sorts an array user comparison callback method for comparing values preserving key-value associations.

Resets array's intrinsic enumerator.

uksort ( Context ctx, [ array, IPhpCallable compare ) : bool

Sorts an array using user comparison callback for comparing keys.

Resets array's intrinsic enumerator.

usort ( Context ctx, [ array, IPhpCallable compare ) : bool

Sorts an array using user comparison callback for comparing values.

Resets array's intrinsic enumerator.

Private Methods

Method Description
ArrayReplaceImpl ( PhpArray array, PhpArray arrays, bool recursive ) : PhpArray Performs deep copy of array, return array with replacements.
ArrayReplaceImpl ( PhpArray array, PhpArray replaceWith, bool recursive ) : void

Performs replacements on deeply-copied array. Performs deep copies of replace values.

Chunk ( PhpArray array, int size, bool preserveKeys = false ) : PhpArray

Splits an array into chunks.

ChunkInternal ( PhpArray array, int size, bool preserveKeys, bool deepCopy ) : PhpArray

Internal version of Chunk with deep-copy option.

GetComparer ( Context ctx, ComparisonMethod method, SortingOrder order, bool keyComparer ) : PhpValue>>.IComparer

Gets an instance of PHP comparer parametrized by specified method, order, and compared item type.

MergeRecursive ( PhpArray array, bool deepCopy ) : PhpArray

Merges arrays recursively.

MergeRecursiveInternal ( PhpArray result, PhpArray array, bool deepCopy ) : bool

Adds items of "array" to "result" merging those whose string keys are the same.

MultiSortResolveArgs ( Context ctx, PhpArray first, PhpValue args, PhpArray arrays, PhpValue>.IComparer comparers ) : int

Resolves arguments passed to MultiSort method according to PHP manual for array_multisort function.

Arrays and comparers can be a null reference. In such a case only number of arrays to be sorted is returned. Otherwise, arrays is filled with these arrays and comparers with comparers defined by appropriate arguments.

PrepareWalk ( IDictionary array, IPhpCallable callback, PhpValue data ) : Pchp.Core.PhpValue[]

Prepares a walk for array_walk(Context, PhpHashtable, IPhpCallable, PhpValue) and array_walk_recursive(Context, PhpHashtable, IPhpCallable, PhpValue) methods.

RandomSubset ( ICollection source, IList result, int count, Random generator ) : bool

Chooses specified number of items from a collection at random.

Items are chosen uniformly in time O(n), where n is the number of items in the collection using conveyor belt sampling.

RangeOfChars ( char low, char high, int step ) : PhpArray

Creates an array containing range of characters from the [low;high] interval with arbitrary step.

RangeOfDoubles ( double low, double high, double step ) : PhpArray

Creates an array containing range of doubles from the [low;high] interval with arbitrary step.

RangeOfLongInts ( long low, long high, long step ) : PhpArray

Creates an array containing range of long integers from the [low;high] interval with arbitrary step.

SetOperation ( SetOperations op, PhpArray array, PhpArray arrays, PhpValue>.IComparer comparer ) : PhpArray

Internal method common for all functions.

SpliceInternal ( PhpArray array, int offset, int length, PhpValue replacement, bool deepCopy ) : PhpArray

Implementation of array_splice(PhpArray,int,int,object) and array_splice(PhpArray,int,int,object).

Whether to make a deep-copy of items in the replacement.

SplitArraysAndComparers ( int comparerCount, PhpArray array, PhpValue vars, PhpArray &arrays, IPhpCallable &cmp1, IPhpCallable &cmp2 ) : bool

There have to be at least 1 value in vars. The last is converted to callback, the rest to arrays.

StringKeysToLower ( PhpArray array ) : PhpArray

Converts string keys in PhpArray to lower case.

Integer keys as well as all values remain unchanged.

StringKeysToUpper ( PhpArray array ) : PhpArray

Converts string keys in PhpArray to upper case.

Integer keys as well as all values remain unchanged.

VisitEntryOnWalk ( Context ctx, PhpValue>.KeyValuePair entry, PhpValue>.IDictionary array, IPhpCallable callback, PhpValue args ) : void

Visits an entry of array which array_walk(Context, PhpHashtable, IPhpCallable, PhpValue) or array_walk_recursive(Context, PhpHashtable, IPhpCallable, PhpValue) is walking through.

Method Details

array_change_key_case() public static method

Converts string keys in PhpArray to lower case.
Integer keys as well as all values remain unchanged.
public static array_change_key_case ( PhpArray array ) : PhpArray
array Pchp.Core.PhpArray The to be converted.
return Pchp.Core.PhpArray

array_change_key_case() public static method

Converts string keys in PhpArray to specified case.
Integer keys as well as all values remain unchanged.
public static array_change_key_case ( PhpArray array, LetterCase keyCase ) : PhpArray
array Pchp.Core.PhpArray The to be converted.
keyCase LetterCase The to convert keys to.
return Pchp.Core.PhpArray

array_chunk() public static method

Splits an array into chunks.
Chunks will contain deep copies of array items.
public static array_chunk ( PhpArray array, int size, bool preserveKeys = false ) : PhpArray
array Pchp.Core.PhpArray The array to be split.
size int The number of items in each chunk (except for the last one where can be lesser items).
preserveKeys bool Whether to preserve keys in chunks.
return Pchp.Core.PhpArray

array_combine() public static method

Creates an array using one array for its keys and the second for its values.
keys and values should have the same length (zero is adminssible - an empty array is returned). Keys are converted using PHP.Core.Convert.ObjectToArrayKey before hashed to resulting array. If more keys has the same value after conversion the last one is used. If a key is not a legal array key it is skipped. Doesn't dereference PHP references.
or is a null reference. and has different length.
public static array_combine ( PhpArray keys, PhpArray values ) : PhpArray
keys Pchp.Core.PhpArray The keys of resulting array.
values Pchp.Core.PhpArray The values of resulting array.
return Pchp.Core.PhpArray

array_count_values() public static method

Counts frequency of each value in an array.
Only string and int values are counted. Note, string numbers (e.g. "10") and their integer equivalents (e.g. 10) are counted separately.
is a null reference. A value is neither nor .
public static array_count_values ( PhpArray array ) : PhpArray
array Pchp.Core.PhpArray The array which values to count.
return Pchp.Core.PhpArray

array_diff() public static method

Computes the difference of arrays.
Keys are preserved. Entries are considered to be equal iff values compared by by string comparison method are the same (see ValueComparer.String).
is a null reference. is a null reference or an empty array.
public static array_diff ( Context ctx, PhpArray array ) : PhpArray
ctx Pchp.Core.Context Current runtime context.
array Pchp.Core.PhpArray The array from which to take items away.
return Pchp.Core.PhpArray

array_diff_assoc() public static method

Computes the difference of arrays.
Keys are preserved. Entries are considered to be equal iff they has the same keys and values according to string method comparison (see EntryComparer and PhpStringComparer).
is a null reference. is a null reference or an empty array.
public static array_diff_assoc ( Context ctx, PhpArray array ) : PhpArray
ctx Pchp.Core.Context Current runtime context.
array Pchp.Core.PhpArray The array from which to take items away.
return Pchp.Core.PhpArray

array_diff_key() public static method

Computes the difference of arrays.
Entries are considered to be equal iff keys compared by by string comparison method are the same (see KeyComparer.String).
is a null reference. is a null reference or an empty array.
public static array_diff_key ( Context ctx, PhpArray array ) : PhpArray
ctx Pchp.Core.Context Current runtime context.
array Pchp.Core.PhpArray The array from which to take items away.
return Pchp.Core.PhpArray

array_diff_uassoc() public static method

Computes the difference of arrays using a specified comparer.
public static array_diff_uassoc ( Context ctx, PhpArray array, PhpArray array0 ) : PhpArray
ctx Pchp.Core.Context
array Pchp.Core.PhpArray
array0 Pchp.Core.PhpArray
return Pchp.Core.PhpArray

array_diff_ukey() public static method

Computes the difference of arrays using a specified key comparer.
public static array_diff_ukey ( Context ctx, PhpArray array, PhpArray array0 ) : PhpArray
ctx Pchp.Core.Context
array Pchp.Core.PhpArray
array0 Pchp.Core.PhpArray
return Pchp.Core.PhpArray

array_fill() public static method

Creates a new array filled with a specified value.
Thrown if is not positive.
public static array_fill ( int startIndex, int count, PhpValue value ) : PhpArray
startIndex int The value of the key of the first item in the array.
count int The number of items in the array.
value Pchp.Core.PhpValue The value copied to all items in the array.
return Pchp.Core.PhpArray

array_fill_keys() public static method

public static array_fill_keys ( PhpArray keys, PhpValue value ) : PhpArray
keys Pchp.Core.PhpArray
value Pchp.Core.PhpValue
return Pchp.Core.PhpArray

array_filter() public static method

Filters an array using a specified callback.
public static array_filter ( Context ctx, PhpArray array, IPhpCallable callback ) : PhpArray
ctx Pchp.Core.Context Current runtime context.
array Pchp.Core.PhpArray The array to be filtered.
callback IPhpCallable /// The callback called on each value in the . /// If the callback returns value convertible to true the value is copied to the resulting array. /// Otherwise, it is ignored. ///
return Pchp.Core.PhpArray

array_filter() public static method

Retuns the specified array. see http://php.net/manual/en/function.array-filter.php
The caller argument is here just because of the second Filter() method. Phalanger shares the function properties over the overloads.
public static array_filter ( PhpArray array ) : PhpArray
array Pchp.Core.PhpArray
return Pchp.Core.PhpArray

array_flip() public static method

Swaps all keys and their associated values in an array.

Values which are not of type string nor int are skipped and for each such value a warning is reported. If there are more entries with the same value in the array the last key is considered others are ignored. String keys are converted using Core.Convert.StringToArrayKey.

Unlike PHP this method doesn't return false on failure but a null reference. This is because it fails only if array is a null reference.

is a null reference (Warning). A value is neither nor (Warning).
public static array_flip ( PhpArray array ) : PhpArray
array Pchp.Core.PhpArray The array.
return Pchp.Core.PhpArray

array_intersect() public static method

Computes the intersection of arrays.
public static array_intersect ( Context ctx, PhpArray array ) : PhpArray
ctx Pchp.Core.Context
array Pchp.Core.PhpArray
return Pchp.Core.PhpArray

array_intersect_assoc() public static method

Computes the intersection of arrays.
public static array_intersect_assoc ( Context ctx, PhpArray array ) : PhpArray
ctx Pchp.Core.Context
array Pchp.Core.PhpArray
return Pchp.Core.PhpArray

array_intersect_key() public static method

Computes the intersection of arrays.
public static array_intersect_key ( Context ctx, PhpArray array ) : PhpArray
ctx Pchp.Core.Context
array Pchp.Core.PhpArray
return Pchp.Core.PhpArray

array_intersect_uassoc() public static method

Computes the intersection of arrays using a specified comparer.
public static array_intersect_uassoc ( Context ctx, PhpArray array, PhpArray array0 ) : PhpArray
ctx Pchp.Core.Context
array Pchp.Core.PhpArray
array0 Pchp.Core.PhpArray
return Pchp.Core.PhpArray

array_intersect_ukey() public static method

Computes the intersection of arrays using a specified key comparer.
public static array_intersect_ukey ( Context ctx, PhpArray array, PhpArray array0 ) : PhpArray
ctx Pchp.Core.Context
array Pchp.Core.PhpArray
array0 Pchp.Core.PhpArray
return Pchp.Core.PhpArray

array_key_exists() public static method

Checks if a key exists in the array.
key is converted before the search.
argument is a null reference (Warning). has type which is illegal for array key.
public static array_key_exists ( IntStringKey key, PhpArray array ) : bool
key IntStringKey The key to be searched for.
array Pchp.Core.PhpArray The array where to search for the key.
return bool

array_keys() public static method

Retrieves an array of keys contained in a given array.
is a null reference.
public static array_keys ( PhpArray array ) : PhpArray
array Pchp.Core.PhpArray An array which keys to get.
return Pchp.Core.PhpArray

array_keys() public static method

Retrieves an array of some keys contained in a given array.
is a null reference.
public static array_keys ( PhpArray array, PhpValue searchValue, bool strict = false ) : PhpArray
array Pchp.Core.PhpArray An array which keys to get.
searchValue Pchp.Core.PhpValue Only the keys for this value are returned. /// Values are compared using regular comparison method ().
strict bool If true, uses strict comparison method (operator "===").
return Pchp.Core.PhpArray

array_map() public static method

Applies a callback function on specified tuples one by one storing its results to an array.

In the i-th call the j-th parameter of the callback will be the i-th value of the j-the array or a null if that array has less then i entries.

If the callback assigns a value to a parameter passed by reference in the i-the call and the respective array contains at least i elements the assigned value is propagated to the array.

public static array_map ( Context ctx, IPhpCallable map ) : PhpArray
ctx Pchp.Core.Context Current runtime context.
map IPhpCallable /// A callback to be called on tuples. The number of arguments should be the same as /// the number of arrays specified by . /// Arguments passed by reference modifies elements of . /// A null means default callback which makes integer indexed arrays from the tuples is used. ///
return Pchp.Core.PhpArray

array_merge() public static method

Merges one or more arrays. Integer keys are changed to new ones, string keys are preserved. Values associated with existing string keys are be overwritten.
public static array_merge ( ) : PhpArray
return Pchp.Core.PhpArray

array_merge_recursive() public static method

Merges arrays recursively.
Integer keys are reset so there cannot be a conflict among them. Conflicts among string keys are resolved by merging associated values into arrays. Merging is propagated recursively. Merged values are dereferenced. References are preserved in non-merged values.
Some array is a null reference (Warning).
public static array_merge_recursive ( PhpArray array ) : PhpArray
array Pchp.Core.PhpArray The first array to merge.
return Pchp.Core.PhpArray

array_multisort() public static method

Sort multiple arrays.
Reindexes integer keys in the sorted arrays and restarts their intrinsic enumerators.
is a null reference (Warning). Arrays has different lengths (Warning). Invalid sorting flags (Warning). Multiple sorting flags applied on single array (Warning).
public static array_multisort ( Context ctx, [ first ) : bool
ctx Pchp.Core.Context Current runtime context.
first [ The first array to be sorted.
return bool

array_pad() public static method

Pads array to the specified length with a value. If the length is negative adds |length| elements at beginning otherwise adds elements at the end. Values with integer keys that are contained in the source array are inserted to the resulting one with new integer keys counted from zero (or from |length| if length negative).
The argument is a null reference.
public static array_pad ( PhpArray array, int length, PhpValue value ) : PhpArray
array Pchp.Core.PhpArray The source array.
length int The length of the resulting array.
value Pchp.Core.PhpValue The value to add in array.
return Pchp.Core.PhpArray

array_pop() public static method

Removes the last item from an array and returns it.
Resets intrinsic enumerator.
public static array_pop ( PhpArray array ) : PhpValue
array Pchp.Core.PhpArray The array whcih item to pop.
return Pchp.Core.PhpValue

array_product() public static method

Computes a product of all values in an array. Each value is converted to a number in the same way it is done by PHP.
Thrown if the argument is null.
public static array_product ( PhpArray array ) : PhpNumber
array Pchp.Core.PhpArray
return PhpNumber

array_push() public static method

Adds multiple items into an array.
public static array_push ( PhpArray array ) : int
array Pchp.Core.PhpArray The array where to add values.
return int

array_rand() public static method

Chooses specified number of keys from an array at random.
Items are chosen uniformly in time O(n), where n is the number of items in the array using conveyor belt sampling.
is a null reference. is not positive and less /// than the number of items in . (Warning)
public static array_rand ( PhpArray array, int count = 1 ) : PhpValue
array Pchp.Core.PhpArray The from which to choose.
count int The number of items to choose.
return Pchp.Core.PhpValue

array_reduce() public static method

public static array_reduce ( Context ctx, [ array, IPhpCallable function ) : PhpValue
ctx Pchp.Core.Context
array [
function IPhpCallable
return Pchp.Core.PhpValue

array_reduce() public static method

public static array_reduce ( Context ctx, [ array, IPhpCallable function, PhpValue initialValue ) : PhpValue
ctx Pchp.Core.Context
array [
function IPhpCallable
initialValue Pchp.Core.PhpValue
return Pchp.Core.PhpValue

array_replace() public static method

array_replace() replaces the values of the first array with the same values from all the following arrays. If a key from the first array exists in the second array, its value will be replaced by the value from the second array. If the key exists in the second array, and not the first, it will be created in the first array. If a key only exists in the first array, it will be left as is. If several arrays are passed for replacement, they will be processed in order, the later arrays overwriting the previous values. array_replace() is not recursive : it will replace values in the first array by whatever type is in the second array.
public static array_replace ( [ array ) : PhpArray
array [ The array in which elements are replaced.
return Pchp.Core.PhpArray

array_replace_recursive() public static method

array_replace_recursive() replaces the values of the first array with the same values from all the following arrays. If a key from the first array exists in the second array, its value will be replaced by the value from the second array. If the key exists in the second array, and not the first, it will be created in the first array. If a key only exists in the first array, it will be left as is. If several arrays are passed for replacement, they will be processed in order, the later array overwriting the previous values. array_replace_recursive() is recursive : it will recurse into arrays and apply the same process to the inner value. When the value in array is scalar, it will be replaced by the value in array1, may it be scalar or array. When the value in array and array1 are both arrays, array_replace_recursive() will replace their respective value recursively.
public static array_replace_recursive ( [ array ) : PhpArray
array [ The array in which elements are replaced.
return Pchp.Core.PhpArray

array_reverse() public static method

Returns array which elements are taken from a specified one in reversed order.
public static array_reverse ( PhpArray array, bool preserveKeys = false ) : PhpArray
array Pchp.Core.PhpArray The array to be reversed.
preserveKeys bool Whether keys should be left untouched. /// If set to false then integer keys are reindexed starting from zero.
return Pchp.Core.PhpArray

array_search() public static method

Searches the array for a given value and returns the corresponding key if successful.
is a null reference (Warning).
public static array_search ( PhpValue needle, PhpArray haystack, bool strict = false ) : PhpValue
needle Pchp.Core.PhpValue The value to search for.
haystack Pchp.Core.PhpArray The where to search.
strict bool Whether strict comparison method (operator ===) is used for comparing values.
return Pchp.Core.PhpValue

array_shift() public static method

Removes the first item of an array and reindex integer keys starting from zero.
Resets intrinsic enumerator.
public static array_shift ( PhpArray array ) : PhpValue
array Pchp.Core.PhpArray The array to be shifted.
return Pchp.Core.PhpValue

array_slice() public static method

Retrieves a slice of specified array.
See PhpMath.AbsolutizeRange for details about offset and length.
public static array_slice ( PhpArray array, int offset, int length = int.MaxValue, bool preserveKeys = false ) : PhpArray
array Pchp.Core.PhpArray The array which slice to get.
offset int The relativized offset of the first item of the slice.
length int The relativized length of the slice.
preserveKeys bool Whether to preserve integer keys. If false, the integer keys are reset.
return Pchp.Core.PhpArray

array_splice() public static method

Removes a slice of an array.

length items are removed from array starting with the offset-th one.

public static array_splice ( PhpArray array, int offset, int length = int.MaxValue ) : PhpArray
array Pchp.Core.PhpArray The array which slice to remove.
offset int The relativized offset of a first item of the slice.
length int The relativized length of the slice.
return Pchp.Core.PhpArray

array_splice() public static method

Replaces a slice of an array with specified item(s).

The same as Splice(PhpArray,int,int,object) except for that replacement items are deeply copied to the array.

public static array_splice ( PhpArray array, int offset, int length, PhpValue replacement ) : PhpArray
array Pchp.Core.PhpArray
offset int
length int
replacement Pchp.Core.PhpValue
return Pchp.Core.PhpArray

array_sum() public static method

Sums all values in an array. Each value is converted to a number in the same way it is done by PHP.
Thrown if the argument is null.
public static array_sum ( PhpArray array ) : PhpNumber
array Pchp.Core.PhpArray
return PhpNumber

array_udiff() public static method

Computes the difference of arrays using a specified comparer.
public static array_udiff ( Context ctx, PhpArray array, PhpArray array0 ) : PhpArray
ctx Pchp.Core.Context
array Pchp.Core.PhpArray
array0 Pchp.Core.PhpArray
return Pchp.Core.PhpArray

array_udiff_assoc() public static method

Computes the difference of arrays using a specified comparer.
public static array_udiff_assoc ( Context ctx, PhpArray array, PhpArray array0 ) : PhpArray
ctx Pchp.Core.Context
array Pchp.Core.PhpArray
array0 Pchp.Core.PhpArray
return Pchp.Core.PhpArray

array_udiff_uassoc() public static method

Computes the difference of arrays using specified comparers.
public static array_udiff_uassoc ( Context ctx, PhpArray array, PhpArray array0 ) : PhpArray
ctx Pchp.Core.Context
array Pchp.Core.PhpArray
array0 Pchp.Core.PhpArray
return Pchp.Core.PhpArray

array_uintersect() public static method

Computes the intersection of arrays using a specified comparer.
public static array_uintersect ( Context ctx, PhpArray array, PhpArray array0 ) : PhpArray
ctx Pchp.Core.Context
array Pchp.Core.PhpArray
array0 Pchp.Core.PhpArray
return Pchp.Core.PhpArray

array_uintersect_assoc() public static method

Computes the intersection of arrays using a specified comparer.
public static array_uintersect_assoc ( Context ctx, PhpArray array, PhpArray array0 ) : PhpArray
ctx Pchp.Core.Context
array Pchp.Core.PhpArray
array0 Pchp.Core.PhpArray
return Pchp.Core.PhpArray

array_uintersect_uassoc() public static method

Computes the intersection of arrays using specified comparers.
public static array_uintersect_uassoc ( Context ctx, PhpArray array, PhpArray array0 ) : PhpArray
ctx Pchp.Core.Context
array Pchp.Core.PhpArray
array0 Pchp.Core.PhpArray
return Pchp.Core.PhpArray

array_unique() public static method

Removes duplicate values from an array.
Values are compared using string comparison method (ValueComparer.String).
is a null reference.
public static array_unique ( Context ctx, PhpArray array, ComparisonMethod sortFlags = ComparisonMethod.String ) : PhpArray
ctx Pchp.Core.Context Current runtime context.
array Pchp.Core.PhpArray The array which duplicate values to remove.
sortFlags ComparisonMethod Specifies how the values are compared to be identical.
return Pchp.Core.PhpArray

array_unshift() public static method

Inserts specified items before the first item of an array and reindex integer keys starting from zero.
public static array_unshift ( PhpArray array ) : int
array Pchp.Core.PhpArray The array to be unshifted.
return int

array_values() public static method

Retrieves an array of values contained in a given array.
Doesn't dereference PHP references.
is a null reference.
public static array_values ( PhpArray array ) : PhpArray
array Pchp.Core.PhpArray An array which values to get.
return Pchp.Core.PhpArray

array_walk() public static method

Applies a user function or method on each element of a specified array or dictionary.
See Walk(PHP.Core.Reflection.DTypeDesc,PhpHashtable,PhpCallback,object) for details.
or are null references.
public static array_walk ( Context ctx, [ array, IPhpCallable function ) : bool
ctx Pchp.Core.Context
array [
function IPhpCallable
return bool

array_walk() public static method

Applies a user function or method on each element (value) of a specified dictionary.
or are null references.
public static array_walk ( Context ctx, [ array, IPhpCallable callback, PhpValue data ) : bool
ctx Pchp.Core.Context Current runtime context.
array [ The array (or generic dictionary) to walk through.
callback IPhpCallable /// The callback called for each element of . /// The callback is assumed to have two or three parameters: /// /// /// /// A value of dictionary entry. Can be specified with & modifier which propagates any changes /// make to the argument back to the entry. The dictionary can be changed in this way. /// /// /// A key of dictionary entry. /// /// Value of parameter if it is not a null reference. /// Otherwise, the callback is assumed to have two parameters only. /// /// ///
data Pchp.Core.PhpValue An additional parameter passed to as its third parameter.
return bool

array_walk_recursive() public static method

Applies a user function or method on each element of a specified array recursively.
See Walk(PHP.Core.Reflection.DTypeDesc,PhpHashtable,PhpCallback,object) for details.
or are null references.
public static array_walk_recursive ( Context ctx, [ array, IPhpCallable callback ) : bool
ctx Pchp.Core.Context
array [
callback IPhpCallable
return bool

array_walk_recursive() public static method

Applies a user function or method on each element (value) of a specified dictionary recursively.
Walk.
or are null references.
public static array_walk_recursive ( Context ctx, [ array, IPhpCallable callback, PhpValue data ) : bool
ctx Pchp.Core.Context Current runtime context.
array [ The array to walk through.
callback IPhpCallable The callback called for each element of .
data Pchp.Core.PhpValue An additional parameter passed to as its third parameter.
return bool

arsort() public static method

Sorts an array using specified comparison method for comparing values in reverse order preserving key-value associations.
Resets array's intrinsic enumerator.
public static arsort ( Context ctx, [ array, ComparisonMethod comparisonMethod = ComparisonMethod.Regular ) : bool
ctx Pchp.Core.Context Current runtime context.
array [ The array to be sorted.
comparisonMethod ComparisonMethod The method to be used for comparison of values.
return bool

asort() public static method

Sorts an array using specified comparison method for comparing values preserving key-value associations.
Resets array's intrinsic enumerator.
public static asort ( Context ctx, [ array, ComparisonMethod comparisonMethod = ComparisonMethod.Regular ) : bool
ctx Pchp.Core.Context Current runtime context.
array [ The array to be sorted.
comparisonMethod ComparisonMethod The method to be used for comparison of values.
return bool

current() public static method

Retrieves a value being pointed by an array intrinsic enumerator.
The value returned is dereferenced.
public static current ( IPhpEnumerable array ) : PhpValue
array IPhpEnumerable The array which current value to return.
return Pchp.Core.PhpValue

each() public static method

Retrieves the current entry and advances array intrinsic enumerator one item forward.
public static each ( IPhpEnumerable array ) : PhpArray
array IPhpEnumerable The array which entry get and which intrinsic enumerator to advance.
return Pchp.Core.PhpArray

end() public static method

Moves array intrinsic enumerator so it will point to the last item of the array.
The value returned is dereferenced.
public static end ( IPhpEnumerable array ) : PhpValue
array IPhpEnumerable The array which intrinsic enumerator to move.
return Pchp.Core.PhpValue

in_array() public static method

Checks if a value exists in an array.
is a null reference (Warning).
public static in_array ( PhpValue needle, PhpArray haystack, bool strict = false ) : bool
needle Pchp.Core.PhpValue The value to search for.
haystack Pchp.Core.PhpArray The where to search.
strict bool Whether strict comparison method (operator ===) is used for comparing values.
return bool

key() public static method

Retrieves a key being pointed by an array intrinsic enumerator.
public static key ( IPhpEnumerable array ) : PhpValue
array IPhpEnumerable The array which current key to return.
return Pchp.Core.PhpValue

key_exists() public static method

Alias of array_key_exists.
public static key_exists ( IntStringKey key, PhpArray array ) : bool
key IntStringKey
array Pchp.Core.PhpArray
return bool

krsort() public static method

Sorts an array using specified comparison method for comparing keys in reverse order.
Resets array's intrinsic enumerator.
public static krsort ( Context ctx, [ array, ComparisonMethod comparisonMethod = ComparisonMethod.Regular ) : bool
ctx Pchp.Core.Context Current runtime context.
array [ The array to be sorted.
comparisonMethod ComparisonMethod The method to be used for comparison of keys.
return bool

ksort() public static method

Sorts an array using specified comparison method for comparing keys.
Resets array's intrinsic enumerator.
public static ksort ( Context ctx, [ array, ComparisonMethod comparisonMethod = ComparisonMethod.Regular ) : bool
ctx Pchp.Core.Context Current runtime context.
array [ The array to be sorted.
comparisonMethod ComparisonMethod The method to be used for comparison of keys.
return bool

natcasesort() public static method

Sorts an array using case insensitive natural comparison method for comparing values preserving key-value association.
Resets array's intrinsic enumerator.
public static natcasesort ( Context ctx, [ array ) : bool
ctx Pchp.Core.Context Current runtime context.
array [ The array to be sorted.
return bool

natsort() public static method

Sorts an array using case sensitive natural comparison method for comparing values preserving key-value association.
Resets array's intrinsic enumerator.
public static natsort ( Context ctx, [ array ) : bool
ctx Pchp.Core.Context Current runtime context.
array [ The array to be sorted.
return bool

next() public static method

Advances array intrinsic enumerator one item forward.
The value returned is dereferenced.
public static next ( IPhpEnumerable array ) : PhpValue
array IPhpEnumerable The array which intrinsic enumerator to advance.
return Pchp.Core.PhpValue

pos() public static method

Retrieves a value being pointed by an array intrinsic enumerator.
Alias of current. The value returned is dereferenced.
public static pos ( IPhpEnumerable array ) : object
array IPhpEnumerable The array which current value to return.
return object

prev() public static method

Moves array intrinsic enumerator one item backward.
The value returned is dereferenced.
public static prev ( IPhpEnumerable array ) : PhpValue
array IPhpEnumerable The array which intrinsic enumerator to move.
return Pchp.Core.PhpValue

range() public static method

Creates an array containing range of elements with step 1.
public static range ( Context ctx, PhpValue low, PhpValue high ) : PhpArray
ctx Pchp.Core.Context Current runtime context.
low Pchp.Core.PhpValue Lower bound of the interval.
high Pchp.Core.PhpValue Upper bound of the interval.
return Pchp.Core.PhpArray

range() public static method

Creates an array containing range of elements with arbitrary step.
Implements PHP awful range function. The result depends on types and content of parameters under the following rules: If at least one parameter (low, high or step) is of type double or is a string wholly representing double value (i.e. whole string is converted to a number and no chars remains, e.g. "1.5" is wholly representing but the value "1.5x" is not) than range of double values is generated with a step treated as a double value (e.g. range("1x","2.5x","0.5") = array(1.0, 1.5, 2.0, 2.5) etc.) otherwise if at least one bound (i.e. low or high parameter) is of type int or is a string wholly representing integer value than range of integer values is generated with a step treated as integer value (e.g. range("1x","2","1.5") = array(1, 2, 3, 4) etc.) otherwise low and high are both non-empty strings (otherwise one of the two previous conditions would be true), so the first characters of these strings are taken and a sequence of characters is generated. Moreover, if low is greater than high then descending sequence is generated and ascending one otherwise. If step is less than zero than an absolute value is used.
Thrown if the argument is zero (or its absolute value less than 1 in the case 2).
public static range ( Context ctx, PhpValue low, PhpValue high, PhpValue step ) : PhpArray
ctx Pchp.Core.Context Current runtime context.
low Pchp.Core.PhpValue Lower bound of the interval.
high Pchp.Core.PhpValue Upper bound of the interval.
step Pchp.Core.PhpValue The step.
return Pchp.Core.PhpArray

range() public static method

Creates an array containing range of elements with step 1.
public static range ( long low, long high ) : PhpArray
low long Lower bound of the interval.
high long Upper bound of the interval.
return Pchp.Core.PhpArray

reset() public static method

Moves array intrinsic enumerator so it will point to the first item of the array.
The value returned is dereferenced.
public static reset ( IPhpEnumerable array ) : PhpValue
array IPhpEnumerable The array which intrinsic enumerator to move.
return Pchp.Core.PhpValue

rsort() public static method

Sorts an array using specified comparison method for comparing values in reverse order.
Resets array's intrinsic enumerator.
public static rsort ( Context ctx, [ array, ComparisonMethod comparisonMethod = ComparisonMethod.Regular ) : bool
ctx Pchp.Core.Context Current runtime context.
array [ The array to be sorted.
comparisonMethod ComparisonMethod The method to be used for comparison of keys.
return bool

shuffle() public static method

Randomizes the order of elements in the array using PhpMath random numbers generator.
Reindexes all keys in the resulting array.
Thrown if the argument is null.
public static shuffle ( PhpArray array ) : bool
array Pchp.Core.PhpArray
return bool

sort() public static method

Sorts an array using specified comparison method for comparing values.
Resets array's intrinsic enumerator.
public static sort ( Context ctx, [ array, ComparisonMethod comparisonMethod = ComparisonMethod.Regular ) : bool
ctx Pchp.Core.Context Current runtime context.
array [ The array to be sorted.
comparisonMethod ComparisonMethod The method to be used for comparison of values.
return bool

uasort() public static method

Sorts an array user comparison callback method for comparing values preserving key-value associations.
Resets array's intrinsic enumerator.
public static uasort ( Context ctx, [ array, IPhpCallable compare ) : bool
ctx Pchp.Core.Context Current runtime context.
array [ The array to be sorted.
compare IPhpCallable The user callback to be used for comparison of values.
return bool

uksort() public static method

Sorts an array using user comparison callback for comparing keys.
Resets array's intrinsic enumerator.
public static uksort ( Context ctx, [ array, IPhpCallable compare ) : bool
ctx Pchp.Core.Context Current runtime context.
array [ The array to be sorted.
compare IPhpCallable The user callback to be used for comparison of values.
return bool

usort() public static method

Sorts an array using user comparison callback for comparing values.
Resets array's intrinsic enumerator.
public static usort ( Context ctx, [ array, IPhpCallable compare ) : bool
ctx Pchp.Core.Context Current runtime context.
array [ The array to be sorted.
compare IPhpCallable The user callback to be used for comparison of values.
return bool