Forum Moderators: open
My lists are in hand-coded HTML, and if I try to copy and paste them into Excel to alphabetize them, the HREF linking information gets deleted.
How can I alphabetize my lists of links (other than manually copying and pasting them one by one in proper order myself)?
Thanks!
wiggy
Here's some PHP that will do it:
<?php
echo "<pre>";
$pattern = "/<a[\s]+[^>]*?href[\s]?\=[\s\"\']*([\w:?=@&\/#._;-]+)[\s\"\']*.*?\>([^<]+¦.*?)?<\/a>/";
preg_match_all($pattern, file_get_contents("http://www.google.com/"), $matches);
array_multisort($matches[2],$matches[1]);
for($i=0;$i<count($matches[0]);$i++){
echo $matches[2][$i], ',', $matches[1][$i], "\n";
}
echo "</pre>";
?>
Andrew