Tachu Posted March 19, 2006 Share Posted March 19, 2006 Ok i'm just trying to make a list of links stored in an array. I have tried with PHP with different codes and didn't work.1st code: <?php$info = array('link1', 'http://link1.com', 'link2', 'http://link2.com');foreach($info as $link) {echo "<a href='$link'>$name</a>";}?> 2nd Code: <?php$info = array('link1', 'http://link1.com', 'link2', 'http://link2.com');list($name, $link)echo "<a href='$link'>$name</a>";?> So then I tried with javascript... <script type="text/javascript">var links = []links[0] = [ "link1" , "http://link1.com" ]links[1] = [ "link2" , "http://link2.com" ]links[2] = [ "link3" , "http://link3.com" ]for(i=0;i<links.length;i++){document.write ('<a href='" + links[i][1] + "'>" + links[i][0] +"</a>');}</script> And it still didn't workCan anyone help me please? Link to comment Share on other sites More sharing options...
Tachu Posted March 19, 2006 Author Share Posted March 19, 2006 Forget it. I finally got it to work.Final code: <?php$info = array('link1' => 'http://link1.com', 'link1' => 'http://link2.com');foreach($info as $name => $link) {echo "<a href='$link'>$name</a><br>";}?> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now