Mailinglisten-Archive |
on 13.08.2001 17:07 Uhr, Nicolas L=F6we wrote using loewe_(at)_forheads.de:
> die meldung bekommst du, wenn du ein Array einfach ausgeben willst.
>=20
> echo"$array";
>=20
> Du musst ausgeben
>=20
> echo"$array[$n]";
ja, und genau deshalb will ich ja auch jedes wieder mit explode() trennen,
hier ist mein code, wie ich das erreichen will:
// open old file
$file=3D_(at)_fopen("news.db","r");
// do loop until end of file
while(feof($file)=3D=3D0){
$line=3Dchop(fgets($file,1000));
// add line to array
$news_array[]=3D$line;
}
// close files
fclose($file);
// reverse sorting array
rsort ($news_array);
// count elements in array
$number =3D count($news_array);
// print heading of table
echo "<table border=3D0 cellspacing=3D0 cellpadding=3D0>";
// do loop until last array
for ($i =3D 0; $i < $number; $i++)
{
=20
// divide in array
$tokens =3D explode("#",$news_array);
=20
// output to browser
echo "<tr align=3Dleft valign=3Dtop>";
echo "<td colspan=3D2>$tokens[0]</td>";
echo "</tr>";
echo "<tr align=3Dleft valign=3Dtop>";
echo "<td>$tokens[4]</td>";
echo "<td><i>$tokens[1]</i> - $tokens[3]<br><i>$tokens[2]</i>";
=20
// is link given?
if ( $tokens[5]<>"" ){
echo "<br><a href=3D$tokens[5] target=3D_blank>$tokens[5]</a></td>";
}else{
echo "</td>";
}
echo "</tr>";
=20
// jump to next array
next($news_array);
}
// print end of table
echo "</table>";
der soll nun jede zeile einlesen und dem array hinzuf=FCgen, dann rekursive
reihenfolge, dann jeden wert im array einlesen, teilen bei "#" die einzelne=
n
werte ausgeben, und n=E4chsten eintrag im array nehmen und wieder, teilen bei
"#" einzelne werte ausgeben, n=E4chstes array. eigendlich doch dann wie im
wuellcode oben... aber wo ist der haken?
lennart
--=20
[mephisto] & [Ev1L] | m3phi5t0_(at)_m3phi5t0.de
[mephisto] webdesign/graphix/coding (english) | http://www.m3phi5t0.de
[mephisto] webdesign/graphix/coding (deutsch) | http://www.lennart.ch.vu
[webspace] free: 15mb, cgi, php4, mysql, ftp | http://www.whewsites.com
php::bar PHP Wiki - Listenarchive