Hey there,
I am using some very basic PHP to return data to a webpage from a text file.
I am currently using include and explode.
I only want to return 1 element from the first line of the text file, no matter how many lines are there. I figured out how to pick which element, so I am good there. What I can’t figure out is how to return only 1, even if there are multiple lines in the text file.
Here’s my code so far:
<?php
global $settings, $lang;
$file = file("phpencoding.txt"); // Open the file.txt
foreach ($file as $line) { // Now open it and read it line by line
$str = explode(" ",$line); // Explode on the tab on each line from the file
echo '<h3 style="text-align:center">'.$settings['gbook_title']. ' $' .$str[1]. '</h3>'; // Now show the 2nd string the line
}
?>
any ideas?
Thanks!