FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Destroying an stdclass element





pollux1er
Please I want to know how to destroy an stdclass element.
My script is this one
Code:

foreach($articles as $article) {
                  if($i->idcontent != $article->id) unset($article);
                  //
               }

$articles is an array of stdclass element with that loop, i need to unset some elements of the array.

Thanks in advance
jmraker
Since $article is a temporary variable assigned on every loop iteration, You could try unsetting the item in the real array. I added the $k variable.

Code:
foreach($articles as $k=>$article) {
                  if($i->idcontent != $article->id)
                              unset($articles[$k]);
}


or you can set it to null and check for null values later

Code:
foreach($articles as $k=>$article) {
                  if($i->idcontent != $article->id)
                               $articles[$k] = null;
}
Related topics
Medical Absolutism, Cary Angell
Buddhism
The Honda Element commercials
The Middle East Conflict
Rockman ZX Walkthrough
Javascript Add Element
The Game creation topic! - Share experience - Find resources
God and animal rights
Philosophy Essays & Philosophy Texts
Fifth Element
XHTML and background element.
Position of an element in a web page
fatal error in Joomla installation "index.php"
Megaman Phoenix
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.