Skip to content

Commit 6386111

Browse files
committed
add example remove empty data to array to README
1 parent e937d3f commit 6386111

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,70 @@ Arrays::emptyToNull($array, true);
618618
*/
619619
```
620620

621+
**REMOVE EMPTY data to array**
622+
623+
Data:
624+
```php
625+
$array = [
626+
0 => ' first 1 ',
627+
'key1' => false,
628+
1 => '',
629+
2 => '0',
630+
'key4' => null,
631+
3 => [
632+
0 => ' first 3',
633+
1 => false,
634+
'key2' => '',
635+
2 => '0',
636+
'key5' => null,
637+
'key6' => 12,
638+
3 => [],
639+
4 => 'first 4 '
640+
],
641+
4 => true,
642+
5 => [],
643+
'key8' => 'first 2 '
644+
];
645+
```
646+
647+
Example:
648+
```php
649+
Arrays::removeEmpty($array);
650+
/**
651+
* [
652+
* 0 => ' first 1 ',
653+
* 3 => [
654+
* 0 => ' first 3',
655+
* 1 => false,
656+
* 'key2' => '',
657+
* 2 => '0',
658+
* 'key5' => null,
659+
* 'key6' => 12,
660+
* 3 => [],
661+
* 4 => 'first 4 '
662+
* ],
663+
* 4 => true,
664+
* 'key8' => 'first 2 '
665+
* ]
666+
*/
667+
668+
Recursive:
669+
```php
670+
Arrays::removeEmpty($array, true);
671+
/**
672+
* [
673+
* 0 => ' first 1 ',
674+
* 3 => [
675+
* 0 => ' first 3',
676+
* 'key6' => 12,
677+
* 4 => 'first 4 '
678+
* ],
679+
* 4 => true,
680+
* 'key8' => 'first 2 '
681+
* ]
682+
*/
683+
```
684+
621685

622686
## License
623687

0 commit comments

Comments
 (0)