Examples
banshee/examples-collection/examples/mechanics/
lists
Example: arrays and the list tools, count, has, get, add; the TCP ports a Linux listens on.
by banshee1 installation1 version
Published on October 27, 2026. First version in this collection.
Lists
Building and reading arrays, and the tools of the list domain, on the TCP ports a Linux listens on, against those expected.
How to read it
$ports = array();: an empty array. An array is a value: passing it to a function or another variable copies it.$ports[$m[2]][$m[1]] = true;: writing under a key that is missing creates it, and what is missing above it. The variable itself must exist first.list.count: the number of elements.list.has($ports, $port): is there an element under this key.list.get($closed, 0, ''): the element, or the default when the key is missing.list.add($closed, $port): the list with one more element at its end.$a[] = $xdoes not exist in Keen.- A key is a text:
$ports[22]and$ports['22']are the same element.
To adapt it
foreach ($ports as $port => $addresses)goes over the keys and the values (seeexamples/watches/deviate).- To return one value per port, declare a
per(seeexamples/mechanics/selection).