I am trying to remove the first two elements in an Object. For example, if I wanted to remove the first two elements from an array, I would use array_slice ($ arrayName, 2).
I tried this on my facility (hey, why not? I know this is not a technically array, but I am optimistic) and it did not work.
When searching for this, all I found were methods to remove elements from arrays.
$categories = array_slice(Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*'), 2);
foreach($categories as $category){
echo "<div class='col'>{$category->getName()}</div>";
}
In the above example, I would like to remove the first two categories from the object $categories(which are the “Root Category” and “Default” objects) before starting it through the foreach loop. What would be the best way to do this? I know what I can do;
if($category->getName() != 'Root Category' && $category->getName() != 'Default'){
echo $category->getName();
}
But this seems like a dirty decision.
Edit
Patrick Q, , . , array_slice ? , array_slice .
2
. .
, ( ) , , . , , array_slice() . , , , , Magento . , , , .