readline_list_history
(PHP 4, PHP 5, PHP 7, PHP 8)
readline_list_history — ヒストリを一覧表示する
パラメータ
この関数にはパラメータはありません。
戻り値
コマンドラインヒストリ全体の配列を返します。 各要素にはゼロから始まる整数の添字が付加されています。
+add a note
User Contributed Notes 2 notes
info () gaj ! design ¶
8 years ago
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.)
↑ and ↓ to navigate •
Enter to select •
Esc to close
Press Enter without
selection to search using Google