I have a multi dimensional array that is printing out exactly how I want it, however, I have become stuck on figuring out how I can construct it into the for each loop that i'm looking for.
Please Note : $handle is a field the client entered in the 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 i wish to spit this out as an unordered list so i have the below, but its still not working for me.
<ul>
<?php foreach ($social_array as $name => $group) :?>
<?php foreach ($group as $class => $url) :?>
<li><a href="<?php echo ("$url"); ?>" class="<?php echo ("$class;") ?>"><?php echo ("$group"); ?></a></li>
<?php endforeach; ?>
<?php endforeach; ?>
</ul>
I would like it so that it loops through all the social array and prins something similar to this
<li><a href="<?php echo ($url);?><?php echo ($handle);?>" class="<?php echo ($class); ?>"><?php echo $name; ?></a></li>
or so understood better
<li><a href="http://www.facebook.com/handle" class="facebook">Facebook</a></li>
Also if I'm making this over complicated for myself please let me know.