Perhaps someone can help with this, I'm stuck!
I have the following piece of PHP code that grabs data (URLs and Link Titles) from session data. As written, the echo statement outputs something like the following as a list:
The starting point code is:
<?php
function comp($a, $b)
{
if ($a['link_url'] == $b['link_url']) {
return 0;
}
return ($a['link_url'] < $b['link_url']) ? -1 : 1;
}
if ($_SESSION['_am_links'])
{
usort($_SESSION['_am_links'],'comp');
foreach ($_SESSION['_am_links'] as $link_id => $link)
{
echo "<li><a href=\"".$link['link_url']."\">".$link['link_title']."</a></li>";
}
}
?>
This code works but I am trying to revise it so that the url's ('link_url") are sorted and only the highest (in an ahpa sort - /Link03/ in this case) is used to to make a PHP include with the domain portion removed and ".php" added. The desired output would be:
<?php include("Link03.php"); ?>
If the data set went up to "Link08" then the result returned would be:
<?php include("Link08.php"); ?>
Any help would be GREATLY appreciated!
Many Thanks
John