JankaZ Posted April 14, 2010 Share Posted April 14, 2010 Plzz somebody show code how to get for example 10 lines from php file. Read line from php file is same like text file. I how chat bot and it save all talk and i vana echo last 10 lines For example: Me: Hello<br/> Bot: Hi<br/> Me: how ar you?<br/> Bot: Nice!<br/> Me: Version<br/> Bot: V.1<br/> Me: Nice day!<br/> Bot: Jes.<br/> Me: By.<br/> Bot: By!<br/> And all time show now lines ad i whana echo 10 lines to user ken see! Plzz somebody show code or help! Link to comment https://forums.phpfreaks.com/topic/198557-get-line-from-php/ Share on other sites More sharing options...
aeroswat Posted April 14, 2010 Share Posted April 14, 2010 Plzz somebody show code how to get for example 10 lines from php file. Read line from php file is same like text file. I how chat bot and it save all talk and i vana echo last 10 lines For example: Me: Hello<br/> Bot: Hi<br/> Me: how ar you?<br/> Bot: Nice!<br/> Me: Version<br/> Bot: V.1<br/> Me: Nice day!<br/> Bot: Jes.<br/> Me: By.<br/> Bot: By!<br/> And all time show now lines ad i whana echo 10 lines to user ken see! Plzz somebody show code or help! Where does it save it to? I think what you are looking for is right here http://php.net/manual/en/function.file.php Then assuming you know functions for array searching and manipulation you can figure out the rest. Link to comment https://forums.phpfreaks.com/topic/198557-get-line-from-php/#findComment-1041931 Share on other sites More sharing options...
JankaZ Posted April 15, 2010 Author Share Posted April 15, 2010 Jes its like I nide! But how ken i put to echo only 10 lines! <?php // Get a file into an array. In this example we'll go through HTTP to get // the HTML source of a URL. $lines = file('http://www.example.com/'); // Loop through our array, show HTML source as HTML source; and line numbers too. foreach ($lines as $line_num => $line) { echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br />\n"; } // Another example, let's get a web page into a string. See also file_get_contents(). $html = implode('', file('http://localhost/bot/')); // Using the optional flags parameter since PHP 5 $trimmed = file('atbildes.php', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); ?> Link to comment https://forums.phpfreaks.com/topic/198557-get-line-from-php/#findComment-1042156 Share on other sites More sharing options...
Ken2k7 Posted April 15, 2010 Share Posted April 15, 2010 Instead of a foreach use a standard for loop and iterate from 0 to 9. That should be ten. Link to comment https://forums.phpfreaks.com/topic/198557-get-line-from-php/#findComment-1042187 Share on other sites More sharing options...
JankaZ Posted April 15, 2010 Author Share Posted April 15, 2010 Kan you give simple code example becose im beginer! Link to comment https://forums.phpfreaks.com/topic/198557-get-line-from-php/#findComment-1042423 Share on other sites More sharing options...
Ken2k7 Posted April 15, 2010 Share Posted April 15, 2010 Click here - PHP For Loop Results Link to comment https://forums.phpfreaks.com/topic/198557-get-line-from-php/#findComment-1042425 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.