0

I'm working on orphan kid information I was see this link menu, But I don't know how to connect with my page following code:

link: http://example.com/?m=content&a=kidinfo

<?php
$m = array(             
array("title"=>"Home page", "link"=>"?m=index"),            
array("title"=>"Kids Info", "link"=>"?m=content&a=kidinfo"),                
array("title"=>"Gallery", "link"=>"?m=content&a=gal"),                              
array("title"=>"Location", "link"=>"?m=content&a=loc"),             
array("title"=>"About", "link"=>"?m=content&a=about"),              
);
?>
1
  • What exactly do want to achieve ??? Commented Oct 1, 2012 at 20:28

1 Answer 1

1

If I understand correctly, you want to do something along the lines of this to populate your array...

<?php
$baseURL = "http://example.com/";
$m = array(             
array("title"=>"Home page", "link"=>"?m=index"),            
array("title"=>"Kids Info", "link"=>"?m=content&a=kidinfo"),                
array("title"=>"Gallery", "link"=>"?m=content&a=gal"),                              
array("title"=>"Location", "link"=>"?m=content&a=loc"),             
array("title"=>"About", "link"=>"?m=content&a=about"),              
);
?>

Then, when you want to output your links, you can do something along the lines of...

<?php
foreach($m as $link) {
    $path = $baseURL . $link["link"];
    $title = $link["title"];
    echo "<a href='$path'>$title</a>";
  }
?>

Another way to write that foreach block is as follows...

<?php foreach($m as $link): ?>
<a href='<?= $baseURL . $link["link"] ?>'><?= $link["title"] ?></a>
<?php endforeach; ?>

The first is easier to understand for beginners, the second assumes that you have php's short tags enabled.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.