Skip to content

Commit

Permalink
More docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Smoren committed Mar 17, 2024
1 parent 302b6a6 commit 98906bd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ composer require smoren/array-view

## Usage
## Quick examples
### Slicing
### Indexing and Slicing
```php
use Smoren\ArrayView\Views\ArrayView;

Expand Down
20 changes: 20 additions & 0 deletions src/Selectors/PipeSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,26 @@
* $subview[':'] = [55, 77];
* print_r($originalArray); // [1, 2, 3, 4, 55, 6, 77, 8, 9, 10]
* ```
*
* ##### Example with nested pipes
* ```php
* $originalArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
* $selector = new PipeSelector([
* new SliceSelector('::2'),
* new PipeSelector([
* new MaskSelector([true, false, true, true, true]),
* new IndexListSelector([0, 1, 2]),
* ])
* new SliceSelector('1:'),
* ]);
*
* $view = ArrayView::toView($originalArray);
* $subview = $view->subview($selector);
* print_r($subview[':']); // [5, 7]
*
* $subview[':'] = [55, 77];
* print_r($originalArray); // [1, 2, 3, 4, 55, 6, 77, 8, 9, 10]
* ```
*/
final class PipeSelector implements PipeSelectorInterface
{
Expand Down

0 comments on commit 98906bd

Please sign in to comment.