Haumis wbb hilfe (http://haumis-wbb-hilfe.de/wbb2/index.php)
- WBB2 (http://haumis-wbb-hilfe.de/wbb2/board.php?boardid=3)
-- Es klappt nicht (http://haumis-wbb-hilfe.de/wbb2/board.php?boardid=48)
--- Woche auslesen und ausgeben (http://haumis-wbb-hilfe.de/wbb2/thread.php?threadid=2784)


Geschrieben von Listiger_Falke am 23.10.2015 um 21:51:

  Woche auslesen und ausgeben

Ich bin grade dabei einen Horoskopescript zu basteln, und wollte auf der Hauptseite die Woche ausgeben.

Die Ausgabe sollte über die Variable $ausgabe stattfinden, und das ganze aus einem Textdokument ausgelesen werden. Allerdings erhalte ich ..... nichts.

Könnte mir dabei jemand auf die Sprünge helfen?

Meine PHP

php:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
<?php
$filename="ds_horoskop.php";
require("global.php");
require('./acp/lib/class_parse.php');
if(!$wbbuserdata['userid']) access_error();

if(isset($_REQUEST['action'])) $action=$_REQUEST['action'];
else $action="index";

if($action=="index") {

$sprueche file("horoskopwoche.txt");
$ausgabe "";

 foreach ($sprueche as $spruch) 
 {
 list($woche$text) = explode("|"$spruch);
 if ($woche == date("z")) 
 {
 $ausgabe .= $text "<br>\n";
 }
 }
eval("\$tpl->output("".$tpl->get("ds_horoskopindex")."");");
}
?>


Das Textdokument (Ist erst mal nur ein Test)

code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
1|1.Woche
2|2.Woche
3|3.Woche
4|4.Woche
5|5.Woche
6|6.Woche
7|7.Woche
8|8.Woche
9|9.Woche
10|10.Woche
11|11.Woche
12|12.Woche
13|13.Woche
14|14.Woche
15|15.Woche
16|16.Woche
17|17.Woche
18|18.Woche
19|19.Woche
20|20.Woche
21|21.Woche
22|22.Woche
23|23.Woche
24|24.Woche
25|25.Woche
26|26.Woche
27|27.Woche
28|28.Woche
29|29.Woche
30|30.Woche
31|31.Woche
32|32.Woche
33|33.Woche
34|34.Woche
35|35.Woche
36|36.Woche
37|37.Woche
38|38.Woche
39|39.Woche
40|40.Woche
41|41.Woche
42|42.Woche
43|43.Woche
44|44.Woche
45|45.Woche
46|46.Woche
47|47.Woche
48|48.Woche
49|49.Woche
50|50.Woche
51|51.Woche
52|52.Woche


Packe ich nun in das Template ds_horoskopindex.tpl die Variable $ausgabe .... erscheint nichts. Normalerweise sollte da nun stehen 42. Woche oder 37.Woche usw. (Je nachdem was grade für eine Woche im Jahr ist)



Geschrieben von haumi am 26.10.2015 um 15:45:

 

Hi Falke,
du nimmst zum Vergleich date(z) und das ist:

z Der Tag des Jahres (von 0 beginnend) 0 bis 365

Das heißt er findet den Tag nicht weil in deiner Textdatei nur die Woche drin steht.

versuche es mal mit

W ISO-8601 Wochennummer des Jahres, die Woche beginnt am Montag (hinzugefügt in PHP 4.1.0) Beispiel: 42 (die 42. Woche im Jahr)


LG
haumi


Forensoftware: Burning Board 2.3.6, entwickelt von WoltLab GmbH