Jump to content
php.lv forumi

ir Ok bet vajag lai ir otraadi


tikkai maacos

Recommended Posts

shits kods nolasa links.txt failus pa rindinjaam (no A liidz Z)... viss jau iet smuki bet vajag taa lai tas nolasiitu nevis A-Z bet Z-A

<? 
$n = 1;
$links = array();

$fp = fopen("links.txt", "r");
while (!feof($fp)) {
 $link = fgets($fp, 500);
if($link) {
 $links[$n] = rtrim($link);
 $n++; } }
fclose($fp);
echo "<br> <font color=\"red\"  size=\"+1\"> ";
for ($i=1; $i<=sizeof($links); $i++) {
if ($_GET['xxxx'] == $links[$i]) { echo "$links[$i]"; } else {  echo "<a href=\"?xxxx=".$links[$i]."\">".$links[$i]."</a> "; }
 if ( $i<=(sizeof($links)-1)) { echo " <br>"; } } 

?>

 

shet vinjs to visu izvada..

 

<? $z=$_GET['xxxx'];
include "$z.php";
?>

 

cik daudz kkas jaamina lai skripts lasiitu no apaksas? ja varat tad luudzu paliidat.. :)

Link to comment
Share on other sites

$fp = fopen("links.txt", "r");
while (!feof($fp)) {
 $link = fgets($fp, 500);
if($link) {
 $links[$n] = rtrim($link);
 $n++; } }
fclose($fp);

 

vietā raksti

 

$links = array_reverse(file("links.txt"));

 

Un vēl, lai izmestu tukšās rindas, raksti

 

foreach ($links as $k => $v) {
  $links[$k] = trim($links[$k]);
  if (!links[$k]) unset($links[$k])
}

Edited by GedroX
Link to comment
Share on other sites

×
×
  • Create New...