Jump to content

Get line from php


JankaZ

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.