php - Multidimensional Array - foreach, within a foreach -
i have multi dimensional array printing out how want it, however, have become stuck on figuring out how can construct each loop i'm looking for.
please note : $handle field client entered in backend.
<?php $gp = mage::getstoreconfig('social_code/social_group/google_field'); $ld = mage::getstoreconfig('social_code/social_group/linkedin_field'); $tw = mage::getstoreconfig('social_code/social_group/twitter_field'); $fb = mage::getstoreconfig('social_code/social_group/facebook_field'); $social_array = array( "facebook" => array( 'class' => "facebook", 'url' => 'https://www.facebook.com/', 'handle' => $fb ), "twitter" => array( 'class' => "twitter", 'url' => 'https://www.twitter.com/', 'handle' => $tw ), "linked-in" => array( 'class' => "linked-in", 'url' => 'http://www.linkedin.com/company/', 'handle' => $ld ), "google-plus" => array( 'class' => "google-plus", 'url' => 'https://plus.google.com/', 'handle' => $gp ) ); ?>
now wish spit out unordered list have below, still not working me.
<ul> <?php foreach ($social_array $name => $group) :?> <?php foreach ($group $class => $url) :?> <li><a href="<?php echo ("$url"); ?>" class="<?php echo ("$class;") ?>"><?php echo ("$group"); ?></a></li> <?php endforeach; ?> <?php endforeach; ?> </ul>
i loops through social array , prins similar
<li><a href="<?php echo ($url);?><?php echo ($handle);?>" class="<?php echo ($class); ?>"><?php echo $name; ?></a></li>
or understood better
<li><a href="http://www.facebook.com/handle" class="facebook">facebook</a></li>
also if i'm making on complicated myself please let me know.
<ul> <?php foreach ($social_array $name => $group) :?> <li><a href="<?php echo $group['url'].$group['handle']; ?>" class="<?php echo $group['class']; ?>"><?php echo $name; ?></a></li> <?php endforeach; ?> </ul>
Comments
Post a Comment