Jump to content

[SOLVED] Loading from a test file


KFredje

Recommended Posts

Hi,

 

I started very simple with this page:

 

index.php

<html>
<head>
<?php {
$lang['t48']='Sign guestbook';
}
?>
</head>
<body>
<?php echo $lang['t48']; ?>
</body>
</html>

 

when I look in my browser it shows the right thing. But now I'd like to get all this from an extern text file, but how can I get it working?

 

tnx

Link to comment
Share on other sites

the easy way to get a file's contents is

 

$myvar=file_get_contents("myfile.txt");  //$myvar will contain the string contents of the file myfile.txt

 

if you need to split the string by newlines

$myvar2=explode("\n",$myvar);  //$myvar2 will contain an array with each element being a line of text from $myvar

Link to comment
Share on other sites

so this should be my page then?

 

index.php

<html>
<head>
<?php {
$myvar=file_get_contents("text.txt");
$myvar2=explode("\n",$myvar);}?>
</head>
<body>
<?php echo $lang['t48']; ?>
<?php echo $lang['homebe']; ?>
</body>
</html>

 

and this my text file: (text.txt)

 

$lang['t48']='Sign guestbook<br>';
$lang['homebe']='Welkom op onze site waar je alles vindt over ons eindwerk waaraan we het komende jaar zullen werken (2009-2010).<br>Wij (Pieter Steverlynck, Frederik Van de Velde en Ludovic Avet) zullen de windmolen gebruiken als onderwerp voor onze gip.<br>In dit eindwerk kan een stuklijst, verantwoording van materiaal, technische tekeningen, kleine testjes, sterkteleer, etc. voorkomen.<br>Na afloop zal de gip beschikbaar zijn op deze site.<br><br><img src="images/dot.png" width="100%" height="1px"><br><br><center><a href="mailto:eindwerkwindmolen@hotmail.com" style="text-decoration:none"><font color="red">eindwerkwindmolen@hotmail.com</font></a><br><br></center>';

 

if so, it don't work :S

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.