We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Sometimes it's necessary to preserve the original keys in the WireArray result of the slice method.
Current method:
public function slice($start, $limit = 0) { if($limit) { $slice = array_slice($this->data, $start, $limit); } else { $slice = array_slice($this->data, $start); } $items = $this->makeNew(); $items->import($slice); $items->setTrackChanges(true); return $items; }
Proposed changes to the method:
public function slice($start, $limit = 0, $preserveKeys = false) { if ($limit) { $slice = array_slice($this->data, $start, $limit); } else { $slice = array_slice($this->data, $start); } $items = $this->makeNew(); if ($preserveKeys) { $items->setArray($slice); } else { $items->import($slice); } $items->setTrackChanges(true); return $items; }
This will improve the flexibility of the slice method and will be more aligned with PHP's array_slice method.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Short description of the enhancement
Sometimes it's necessary to preserve the original keys in the WireArray result of the slice method.
Current vs. suggested behavior
Current method:
Proposed changes to the method:
Why would the enhancement be useful to users?
This will improve the flexibility of the slice method and will be more aligned with PHP's array_slice method.
The text was updated successfully, but these errors were encountered: