note 120340 added to function.readline-list-history
| From: | () | Date: | Fri, 16 Dec 2016 02:19:32 +0000 |
| Subject: | note 120340 added to function.readline-list-history | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-208604@lists.php.net to get a copy of this message | ||
I just noticed that all readline functions are available with my php.exe (PHP 7, Cygwin) except for
this one. It would be nice to have it so duplicate lines can be screened.
So to emulate it, I keep a working copy of the history in an array (yeah, extra code/data, but there
are ways to keep the history from getting too large).
Loading is like:
<?php
readline_read_history(HISTFILE);
$hist = file(HISTFILE,FILE_IGNORE_NEW_LINES);
array_shift($hist);
?>
Adding is like:
<?php
if (!in_array($line,$hist)) {
$hist[] = $line;
readline_add_history($line);
}
?>
(One may want to just check the last entry being the same.)
----
Server IP: 72.52.91.14
Probable Submitter: 24.2.176.80
----
Manual Page -- http://php.net/manual/en/function.readline-list-history.php
Edit -- https://master.php.net/note/edit/120340
Del: integrated -- https://master.php.net/note/delete/120340/integrated
Del: useless -- https://master.php.net/note/delete/120340/useless
Del: bad code -- https://master.php.net/note/delete/120340/bad+code
Del: spam -- https://master.php.net/note/delete/120340/spam
Del: non-english -- https://master.php.net/note/delete/120340/non-english
Del: in docs -- https://master.php.net/note/delete/120340/in+docs
Del: other reasons-- https://master.php.net/note/delete/120340
Reject -- https://master.php.net/note/reject/120340
Search -- https://master.php.net/manage/user-notes.php