php variable outside foreach

Solutions on MaxInterview for php variable outside foreach by the best coders in the world

showing results for - "php variable outside foreach"
Alessia
01 May 2020
1$categorySize = array();
2
3<?php  $categories = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*'); 
4         foreach ($categories as $category): 
5         $categorySize = $category->getSize_chart(); 
6         print_r ($categorySize); 
7         endforeach;
8    ?>
9
10print_r($categorySize) //Now you can get it outside the loop 
11
Serena
14 Sep 2018
1$pages = get_pages();
2$pagee = array();
3foreach ($pages as $page) {
4  $pagee[] = $page->post_title;
5}
6echo implode(",",$pagee);
7