\app\framework\Component\StdLib\StdObject\ArrayObjectManipulationTrait

Summary

Methods
Properties
Constants
removeFirst()
removeLast()
implode()
key()
append()
prepend()
removeKey()
map()
merge()
mergeRecursive()
rand()
reverse()
shuffle()
unique()
sortUsingFunction()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

removeFirst()

removeFirst() : $this

remove first element of given array

Returns

$this

removeLast()

removeLast() : $this

remove last element of given array

Returns

$this

implode()

implode(string  $glue, string  $key = null) : string

The method joins the items in a collection.

Parameters

string $glue

The string you wish to place between the values.

string $key

If the value contains arrays or objects, you should pass the key of the attributes you wish to join

Returns

string

key()

key(string|integer|\app\framework\Component\StdLib\StdObject\StringObject\StringObject  $key, null|mixed  $value = null, boolean  $setOnlyIfDoesntExist = false) : $this|mixed|\app\framework\Component\StdLib\StdObject\StringObject\StringObject

Get or update the given key inside current array.

Parameters

string|integer|\app\framework\Component\StdLib\StdObject\StringObject\StringObject $key

Array key

null|mixed $value

If set, the value under current $key will be updated and not returned.

boolean $setOnlyIfDoesntExist

Set the $value only in case if the $key doesn't exist.

Returns

$this|mixed|\app\framework\Component\StdLib\StdObject\StringObject\StringObject

The value of the given key.

append()

append(mixed  $k, mixed  $v = null) : $this

Inserts an element to the end of the array.

If you set both params, that first param is the key, and second is the value, else first param is the value, and the second is ignored.

Parameters

mixed $k
mixed $v

Returns

$this

prepend()

prepend(mixed  $k, mixed  $v = null) : $this

Inserts an element at the beginning of the array.

If you set both params, that first param is the key, and second is the value, else first param is the value, and the second is ignored.

Parameters

mixed $k
mixed $v

Returns

$this

removeKey()

removeKey(  $key) 

remove key in current array

Parameters

$key

map()

map(callable  $call) : \app\framework\Component\StdLib\StdObject\ArrayObject\ArrayObject

The method iterates through the array and passes each value to the given callback. The callback is free to modify the item and return it, thus forming a new ArrayObject of modified items

Parameters

callable $call

Returns

\app\framework\Component\StdLib\StdObject\ArrayObject\ArrayObject

reverse()

reverse(boolean  $preserve = false) : $this

reverse elements order

Parameters

boolean $preserve

Returns

$this

shuffle()

shuffle() : $this

Shuffle elements in the array.

Returns

$this

unique()

unique(integer  $sortFlag = SORT_REGULAR) : $this

Removes duplicate values from an array

Parameters

integer $sortFlag

Sorting type flags:
SORT_REGULAR - compare items normally (don't change types)
SORT_NUMERIC - compare items numerically
SORT_STRING - compare items as strings
SORT_LOCALE_STRING - compare items as strings, based on the current locale.

Returns

$this

sortUsingFunction()

sortUsingFunction(callable  $comparisonFunction) : $this

Sort an array by values using a user-defined comparison function<br /> This function assigns new keys to the elements in array. It will remove any existing keys that may have been assigned, rather than just reordering the keys.<br /> The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second.

Parameters

callable $comparisonFunction

Throws

\app\framework\Component\StdLib\StdObject\ArrayObject\ArrayObjectException

Returns

$this