[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

php: array og seperator eller sådan noget



Ja så har jeg da vist lige brug for min sslug livline igen. Det er lykkes mig at skrive alle variabler til en tekstfil. Nu skal jeg så prøve at hente hele tekstefilen ind i et array og så pringe de enkelte linie ud enkeltvis på det sted i filen hvor jeg skal bruge dem og det er her jeg har problemer. Jeg kan godt printe hele array'et på en gang sådan:

 print("$text_t\n");

men det er ikke det jeg har brug for. Jeg vil gerne kunne printe de enkelte linie ud fra deres plads/nummer i rækkefølgen sådan:

<?php echo $text_t[0].'<br/>'; ?>
<?php echo $text_t[1].'<br/>'; ?>
<?php echo $text_t[2].'<br/>'; ?>
<?php echo $text_t[3].'<br/>'; ?>
<?php echo $text_t[4].'<br/>'; ?>

Men så sker der bare det at den i stede for at skrive de enkelte liner en for en giver mig de enkelte tegne et for et så der er et og andet med seperatore eller noget som jeg ikke har rigtigt fat på.


scriptet i acction her:
http://www.mimoart.ooz.dk/fotofi1.php

Coden:

<?php

//denne conditional bliver først udført når der er noget i post
//hvilket der ikke er i det sekund filen åbnes
if (isset($_POST['submit'])) {
$filename = "majdb.txt";
$text_thing0 = $_POST['text_thing0'];
$text_thing1 = $_POST['text_thing1'];
$text_thing2 = $_POST['text_thing2'];
$text_thing3 = $_POST['text_thing3'];
$text_thing4 = $_POST['text_thing4'];

//her skrives disse variabler til filen når altså de er submetted

$open = fopen($filename, "w"); //w'et gør at filen bliver overskrevet hver gang
fwrite($open, "$text_thing0\r");
fwrite($open, "$text_thing1\r");
fwrite($open, "$text_thing2\r");
fwrite($open, "$text_thing3\r");
fwrite($open, "$text_thing4\r");

//og så lukkes filen.
fclose($open);
}
/*
Eftersom vi starter med at teste om der er noget i poste og når der ikke
er det ja men så går vi lige i vores database fil og henter et indhold
*/

//det stykke som skulle hente tekstfilen til databasen

$file_c = file("majdb.txt");
foreach ($file_c as $text_t) {
 $text_t = trim($text_t);
 print("$text_t\n");
}
$text1 = "Mangler";
$text2 = "<a href=\"#sektion1\">Submit nederst på siden</a><br>";
?>

<html>
<head>
<title>ukendt</title> </head> <body> <br>
<br>
<?php echo $text_t[0].'<br/>'; ?>
<?php echo $text_t[1].'<br/>'; ?>
<?php echo $text_t[2].'<br/>'; ?>
<?php echo $text_t[3].'<br/>'; ?>
<?php echo $text_t[4].'<br/>'; ?>
<form method="post" action="">
0.<br/>
<textarea rows="1" cols="40" name="text_thing0" wrap="physical"><?php echo $text1; ?></textarea><br />
<?php echo $text2; ?><br>
1.<br/>
<textarea rows="1" cols="40" name="text_thing1" wrap="physical"><?php echo $text1; ?></textarea><br />
<?php echo $text2; ?><br>
2.<br/>
<textarea rows="1" cols="40" name="text_thing2" wrap="physical"><?php echo $text1; ?></textarea><br />
<?php echo $text2; ?><br>
3.<br/>
<textarea rows="1" cols="40" name="text_thing3" wrap="physical"><?php echo $text1; ?></textarea><br />
<?php echo $text2; ?><br>
4.<br/>
<textarea rows="1" cols="40" name="text_thing4" wrap="physical"><?php echo $text1; ?></textarea><br />
<?php echo $text2; ?><br>
<a name="sektion1"></a>
<input type="submit" name="submit"/> </form> <?php echo $line; ?>
<!- Ending the form ->
</body>
</html>



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2010-09-01, 02:01 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *