KFredje Posted September 27, 2009 Share Posted September 27, 2009 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 https://forums.phpfreaks.com/topic/175680-solved-loading-from-a-test-file/ Share on other sites More sharing options...
mrgenericuser Posted September 27, 2009 Share Posted September 27, 2009 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 https://forums.phpfreaks.com/topic/175680-solved-loading-from-a-test-file/#findComment-925778 Share on other sites More sharing options...
KFredje Posted September 27, 2009 Author Share Posted September 27, 2009 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:[email protected]" style="text-decoration:none"><font color="red">[email protected]</font></a><br><br></center>'; if so, it don't work :S Link to comment https://forums.phpfreaks.com/topic/175680-solved-loading-from-a-test-file/#findComment-925782 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.