As the number of links in each page may vary, i make use of an array in every page to store the link url and correpsonding link name to be displayed.
I pas this array as an argument to the function in navig.php which is called in everypage to display the navigator bar at the top.
But, with my code, am able to create the array but unable to use its values to print the navig bar. when i try pritning the individual array elements nothing gets printed although am able to see the contents when viewing with print_r() of the whole array.
I know am going wrong with a simple stuff, but unable to figure where ?
Heres my navig.php and the corresponding code in the main page which uses this include file...
Code: Select all
navig.php
<?php
function navig_bar($values) {
?>
<div><table><tr>
<?php
for ($i = 0, $num_links = count($values); $i < $num_links; $i++) {
print '<td><a href="';
print $values[i][0]. '" >';
print $values[i][1]. '</a></td>';
print '<td> </td>';
}
?>
</tr></table></div>
<?php } ?>
-------------------------------
page1.php
include("navig.php");
$links = array('login.php' => 'Login Page');
navig_bar($links);
print_r($links);
print $links[0];
print $links[0][0];