Welcome Guest, Not a member yet? Register   Sign In
unset value from object
#5

[eluser]Jeroen Brussich[/eluser]
I removed all my print_r() and var_dump() in that little method, but let's say I wrote them about 10 times in there Wink

I am indeed rather green on the concept of objects but now I understand I do delete the copy of the instance and not the instance itself.
Code:
foreach($candidates->result() as $candidate)
        {
            $needle    = $candidate->id;
            if(in_array($needle, $haystack))
            {
                unset($candidate);
            }
            print_r($candidate); // gives Undefined variable: candidate, like it should be!
        }

        echo '<pre>';
        var_dump($candidates); // Still prints out all the candidates with doubles!
        echo '</pre>';

But this does not solve my initial problem. How do I remove that particular instance from my object instead of the copy? Big Grin


Messages In This Thread
unset value from object - by El Forum - 11-24-2009, 04:09 AM
unset value from object - by El Forum - 11-24-2009, 04:12 AM
unset value from object - by El Forum - 11-24-2009, 05:24 AM
unset value from object - by El Forum - 11-24-2009, 06:06 AM
unset value from object - by El Forum - 11-24-2009, 06:22 AM
unset value from object - by El Forum - 11-24-2009, 06:38 AM
unset value from object - by El Forum - 11-24-2009, 07:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB