What I'm trying to do is use a temporary object to store values and then reset it back to empty without having to uset($tmpObject); ?
Here is some example code:
class Object { function ResetObject(){ // code to remove all variables in an object here? } } $tmpObject = new Object(); foreach ($myArray as $arr){ $tmpObject->val1 = "string1"; $tmpObject->val2 = "string2"; $tmpObject->val3 = "string3"; $tmpObject->val4 = "string4"; $template->set('tmpObject',$tmpObject); $tmpObject->ResetObject(); }
Anyone have any ideas?
PHP reset() Function"<br>"; echo next($people) . "<br>"; echo reset($people);
The reset() function sets the internal pointer of an array to its first element. It returns the value of the first array element. It returns FALSE if the array is empty.
The Reset function resets a control to its Default property value. Any user changes are discarded. You cannot reset controls that are within a Gallery or Edit form control from outside those controls. You can reset controls from formulas on controls within the same gallery or form.
class Object { function ResetObject() { foreach ($this as $key => $value) { unset($this->$key); } } }
See: Object iteration
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With