Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/krypt0nn/table
Библиотека реализации таблиц данных на PHP 7.4
https://github.com/krypt0nn/table
data-structures php
Last synced: 4 days 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 4 years ago)
- Default Branch: main
- Last Pushed: 2021-04-03T18:05:39.000Z (almost 4 years ago)
- Last Synced: 2024-12-10T04:59:53.314Z (about 1 month 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)