https://github.com/krypt0nn/table
Библиотека реализации таблиц данных на PHP 7.4
https://github.com/krypt0nn/table
data-structures php
Last synced: about 1 year ago
JSON representation
Библиотека реализации таблиц данных на PHP 7.4
- Host: GitHub
- URL: https://github.com/krypt0nn/table
- Owner: krypt0nn
- License: gpl-3.0
- Created: 2021-04-03T18:04:20.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-04-03T18:05:39.000Z (almost 5 years ago)
- Last Synced: 2025-01-06T06:43:35.839Z (about 1 year ago)
- Topics: data-structures, php
- Language: PHP
- Homepage:
- Size: 17.6 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
🚀 Table
**table** - небольшая библиотека для работы с таблицами строк на PHP 7.4+
## Установка
```
composer require krypt0nn/table
```
## Пример работы
### Создание таблицы
```php
columns (['id', 'name'])->items ([
[0, 'Hello'],
[1, 'from'],
[2, 'Russia!']
]);
```
### Получение заголовков, элементов и их количества:
```php
columns ());
print_r ($table->items ());
echo $table->size ();
```
```
Array
(
[0] => id
[1] => name
)
```
```
Array
(
[0] => Array
(
[0] => 0
[1] => Hello
)
[1] => Array
(
[0] => 1
[1] => from
)
[2] => Array
(
[0] => 2
[1] => Russia!
)
)
```
```
3
```
### Вывод части элементов:
```php
foreach (function ($item)
{
echo $item[1] .' ';
});
```
```
Hello from Russia!
```
### Фильтрация элементов:
```php
where (function ($item)
{
return $item[1] == 'hello';
});
```
### Вывод массива элементов:
```php
get ());
```
```
Array
(
[0] => Array
(
[id] => 0
[name] => Hello
)
[1] => Array
(
[id] => 1
[name] => from
)
[2] => Array
(
[id] => 2
[name] => Russia!
)
)
```
### Добавление элементов:
```php
push ([3, 'Alalalalala']);
$table->merge ([
[4, 'Ololo'],
[5. 'Olo lo'],
[6, 'Lo']
]);
```
### Кодирование и декодирование таблицы:
```php
delimiter = "\r\n";
file_put_contents ('table', $table->encode ());
$table = (new Table)->decode (file_get_contents ('table'));
```
table:
```
2
id
name
0
Hello
1
from
2
Russia!
```
Автор: [Подвирный Никита](https://vk.com/technomindlp)