tp TouchPointWP Utilities StringableArray - TenthPres/TouchPoint-WP GitHub Wiki

tp\TouchPointWP\Utilities\StringableArray

A collection of things that can be cast to a string by gluing them together with a simple implode().


  • Full name: \tp\TouchPointWP\Utilities\StringableArray
  • Parent class: ArrayObject

Methods

__construct

StringableArray constructor.

public __construct(object|array $array = [], int $flags = 0, string $iteratorClass = "ArrayIterator"): mixed

Parameters:

Parameter Type Description
$array object|array
$flags int
$iteratorClass string

count

Length of array.

public count(): int

prepend

Append to the start of the array.

public prepend(mixed $value, null $key = null): void

Parameters:

Parameter Type Description
$value mixed
$key null

toArray

Get the stringable array, as an array.

public toArray(): array

contains

Determine if the stringable array (haystack) contains the given needle

public contains(mixed $needle): bool

Parameters:

Parameter Type Description
$needle mixed

keys

Get the keys of the array.

public keys(): array

__toString

Standard method to stringify.

public __toString(): string

join

Link the items together with a given separator, which may be different from the separator used in the constructor.

public join(string|null $separator = null, string|null $prefix = null, string|null $postfix = null): string

Parameters:

Parameter Type Description
$separator string|null
$prefix string|null
$postfix string|null

toListString

Convert the array to a list string with ampersands and such.

public toListString(int $limit = \tp\TouchPointWP\Utilities\PHP_INT_MAX, bool $andOthers = false): string

Parameters:

Parameter Type Description
$limit int
$andOthers bool