gunter Posted December 16, 2018 Posted December 16, 2018 how can I make a copy of an wire array? clone does not work.. $copies = clone $originals; foreach($originals as $original){ $original->title = "this is the original"; } foreach($copies as $copy){ $copy->title = "this is the copy"; } foreach($originals as $original){ echo "<br>this is the original? ".$original->title; } foreach($copies as $copy){ echo "<br>this is the copy? ".$copy->title; } outputs this this is the original? this is the copy this is the original? this is the copy this is the original? this is the copy this is the copy? this is the copy this is the copy? this is the copy this is the copy? this is the copy
gunter Posted December 17, 2018 Author Posted December 17, 2018 importing the wiredata to the new wire array did also not work... so I found out, that the wire data was referenced and not cloned/copied... this works now... $copies = new EventArray(); //new wire array foreach($originals as $key => $original){ $copies[$key] = clone $originals[$key]; //cloning the wiredata does work.. } shall I just put this into a __clone(); method in my wire array?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now