\ArrayClass

Class ArrayClass

Easy array manipulation class

Summary

Methods
Properties
Constants
__construct()
json()
csv()
keys()
values()
sum()
has()
begin()
current()
next()
end()
each()
search()
key_exists()
clear()
raw()
shift()
unshift()
pop()
push()
implode()
filter()
count()
$array
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$array

$array : array

Array manipulated by ArrayClass

Type

array

Methods

__construct()

__construct(array  $array) 

Constructor

Parameters

array $array

json()

json() 

csv()

csv(  $delimiter = ';',   $enclosure = '"') 

Parameters

$delimiter
$enclosure

keys()

keys() : Array|\ArrayClass

Return all the keys of an array.

Due to limitations the additional parameters of array_keys are not supported.

Returns

Array|\ArrayClass

values()

values() : Array|\ArrayClass

Return all the values of an array

Returns

Array|\ArrayClass

sum()

sum() : \number

Calculate the sum of values in an array

Returns

\number

has()

has(mixed  $needle, boolean  $strict = FALSE) : boolean

Checks if a value exists in an array

Parameters

mixed $needle

The searched value

boolean $strict

If true will also compare the types

Returns

boolean

begin()

begin() : mixed

Set the internal pointer of an array to its first element

Returns

mixed —

The first array value

current()

current() : mixed

Return the current element in an array

Returns

mixed

next()

next() : mixed

Advance the internal array pointer of an array

Returns

mixed —

The next array value

end()

end() : mixed

Set the internal pointer of an array to its last element

Returns

mixed —

The last array value

each()

each() : Array|\ArrayClass

Return the current key and value pair from an array and advance the array cursor

Returns

Array|\ArrayClass

search()

search(mixed  $needle, boolean  $strict = FALSE) : mixed

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

Parameters

mixed $needle

The searched value

boolean $strict

If true will also compare the types

Returns

mixed

key_exists()

key_exists(mixed  $key) : boolean

Checks if the given key or index exists in the array

Parameters

mixed $key

Value to check

Returns

boolean

clear()

clear() : Array|\ArrayClass

Remove all elements from the array

Returns

Array|\ArrayClass

raw()

raw() : Array

Return the internal raw Array for this ArrayClass object

Returns

Array

shift()

shift() : mixed

Shift an element off the beginning of array

Returns

mixed

unshift()

unshift(mixed  $value1) : integer

Prepend one or more elements to the beginning of an array

Parameters

mixed $value1

First value to prepend

Returns

integer

pop()

pop() : mixed

Pop the element off the end of array

Returns

mixed

push()

push(mixed  $value1) : integer

Push one or more elements onto the end of array

Parameters

mixed $value1

The first value to append

Returns

integer

implode()

implode(string  $glue = "") : string|\StringClass

Join array elements with a string

Parameters

string $glue

Defaults to an empty string

Returns

string|\StringClass

filter()

filter(Callable  $callback = NULL) : Array|\ArrayClass

Filters elements of an array using a callback function

Parameters

Callable $callback

If this returns true for a value, the value is in the result array.

Returns

Array|\ArrayClass

count()

count(integer  $mode = COUNT_NORMAL) : integer

Count all elements in an array

Parameters

integer $mode

If set to COUNT_RECURSIVE, will recursively count the array.

Returns

integer