Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic PHP clone isn't works correctly #1

Open
GreenMine opened this issue Sep 16, 2021 · 0 comments
Open

Basic PHP clone isn't works correctly #1

GreenMine opened this issue Sep 16, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@GreenMine
Copy link
Owner

GreenMine commented Sep 16, 2021

use RIterator\Iterator;

$string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla luctus fringilla iaculis.";
$separator = ' ';

$split_iterator = Iterator::split_str($string, $separator);
$clone_split_iterator = clone $split_iterator;

echo 'Fifth word of lorem ipsum is: ' . $clone_split_iterator->nth(4) . PHP_EOL;
echo 'Joined back str: ' . $split_iterator->join(' ') . PHP_EOL;

Result:

Fifth word of lorem ipsum is: amet,
Joined back str: Lorem adipiscing elit. Nulla luctus fringilla iaculis.

🤔

@GreenMine GreenMine added the bug Something isn't working label Sep 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant