Menu

## ListItem
in package

ListItem.php : 20

Class ListItem

This class handles array manipulation.

##### Tags

see
  https://www.kotchasan.com/

### Table of Contents

$datas : array<string|int, mixed>
$source : string
assign() : mixed
  Assigns multiple items to the data array.
clear() : mixed
  Clears all data.
count() : int
  Retrieves the total number of items.
delete() : bool
  Deletes the specified item.
firstItem() : mixed
  Retrieves the first item in the array.
get() : mixed
  Retrieves the value at the specified key.
indexOf() : mixed
  Searches for a value in the array.
init() : mixed
  Initializes the class with default values.
insert() : mixed
  Inserts a new item after the specified key.
insertBefore() : mixed
  Inserts a new item before the specified key.
items() : array<string|int, mixed>
  Retrieves all items.
keys() : array<string|int, mixed>
  Retrieves the list of keys.
lastItem() : mixed
  Retrieves the last item in the array.
loadFromFile() : static
  Loads the array from a file.
saveToFile() : bool
  Saves the array to a file.
set() : mixed
  Sets a value at the specified key.
values() : array<string|int, mixed>
  Retrieves all values.
arrayToString() : string
  Converts an array to a string.

### Properties

#### $datas

ListItem.php : 25
`public array<string|int, mixed> $datas`

The data.

#### $source

ListItem.php : 30
`private string $source`

The source file path.

### Methods

#### assign()

ListItem.php : 37

Assigns multiple items to the data array.

`public assign(array<string|int, mixed> $array) : mixed`

##### Parameters

$array : array<string|int, mixed>

  The data to assign.

##### Return values

mixed —

#### clear()

ListItem.php : 49

Clears all data.

`public clear() : mixed`

##### Return values

mixed —

#### count()

ListItem.php : 59

Retrieves the total number of items.

`public count() : int`

##### Return values

int —

The total number of items.

#### delete()

ListItem.php : 72

Deletes the specified item.

`public delete(string $key) : bool`

Returns true if successful, false if not found.

##### Parameters

$key : string

  The key of the item to delete.

##### Return values

bool —

True if the item is deleted successfully, false otherwise.

#### firstItem()

ListItem.php : 86

Retrieves the first item in the array.

`public firstItem() : mixed`

##### Return values

mixed —

The first item.

#### get()

ListItem.php : 99

Retrieves the value at the specified key.

`public get(string $key) : mixed`

Returns the item at the key if found, null otherwise.

##### Parameters

$key : string

  The key to retrieve.

##### Return values

mixed —

The item at the key, or null if not found.

#### indexOf()

ListItem.php : 112

Searches for a value in the array.

`public indexOf(mixed $value) : mixed`

Returns the key of the found item if found, false otherwise.

##### Parameters

$value : mixed

  The value to search for.

##### Return values

mixed —

The key of the found item, or false if not found.

#### init()

ListItem.php : 122

Initializes the class with default values.

`public init(array<string|int, mixed> $config) : mixed`

##### Parameters

$config : array<string|int, mixed>

  The configuration values.

##### Return values

mixed —

#### insert()

ListItem.php : 133

Inserts a new item after the specified key.

`public insert(mixed $key, mixed $item) : mixed`

##### Parameters

$key : mixed

  The key after which the new item will be inserted.

$item : mixed

  The new item.

##### Return values

mixed —

#### insertBefore()

ListItem.php : 155

Inserts a new item before the specified key.

`public insertBefore(mixed $key, mixed $item) : mixed`

##### Parameters

$key : mixed

  The key before which the new item will be inserted.

$item : mixed

  The new item.

##### Return values

mixed —

#### items()

ListItem.php : 172

Retrieves all items.

`public items() : array<string|int, mixed>`

##### Return values

array<string|int, mixed> —

The array of items.

#### keys()

ListItem.php : 182

Retrieves the list of keys.

`public keys() : array<string|int, mixed>`

##### Return values

array<string|int, mixed> —

The array of keys.

#### lastItem()

ListItem.php : 192

Retrieves the last item in the array.

`public lastItem() : mixed`

##### Return values

mixed —

The last item.

#### loadFromFile()

ListItem.php : 204

Loads the array from a file.

`public loadFromFile(string $file) : static`

##### Parameters

$file : string

  The file path to load, including the path.

##### Return values

static —

#### saveToFile()

ListItem.php : 219

Saves the array to a file.

`public saveToFile() : bool`

##### Return values

bool —

True if the array is successfully saved, false otherwise.

#### set()

ListItem.php : 250

Sets a value at the specified key.

`public set(string $key, mixed $value) : mixed`

##### Parameters

$key : string

  The key to set.

$value : mixed

  The value to set.

##### Return values

mixed —

#### values()

ListItem.php : 260

Retrieves all values.

`public values() : array<string|int, mixed>`

##### Return values

array<string|int, mixed> —

The array of values.

#### arrayToString()

ListItem.php : 273

Converts an array to a string.

`private arrayToString(int $indent, array<string|int, mixed> $array) : string`

##### Parameters

$indent : int

  The indentation level.

$array : array<string|int, mixed>

  The array to convert.

##### Return values

string —

The string representation of the array.

## Search results