PDA

View Full Version : Php: Help reversing key after having reversed the array



.Greek.Angel.
October 28th, 2002, 12:03
Can someone help me in here, i made a news system that get's it's info from a txt,
the latest news is at the botom of the txt, so i used an array_reverse to reverse the order,
making the newest article shown on top, but i wan the edit and delete link for each article too,
so i added them, only problem now is, the articles are reveresed but the key's aren't.
Meaning that if i press the delete link of the top article, i get the form to delete the bottom article. and visa versa.
can anyone tell me how to reverse the key's as well, pls? Thx

Salam
October 29th, 2002, 02:37
Dont reverse the array :

<?php
$a = array("1", "2", "3", "4") ;
if(!sizeof($a)) die("No data !") ;
for($i=sizeof($a)-1; $i>=0; $i--) echo $a[$i]."\n" ;
?>
Here keys are not changed .