{"id":526,"date":"2024-11-08T10:31:19","date_gmt":"2024-11-08T10:31:19","guid":{"rendered":"http:\/\/monkey.ploogie.co.uk\/?page_id=526"},"modified":"2026-01-13T09:29:43","modified_gmt":"2026-01-13T09:29:43","slug":"included-main-functions","status":"publish","type":"page","link":"https:\/\/monkey.ploogie.co.uk\/index.php\/included-main-functions\/","title":{"rendered":"Included Main Functions"},"content":{"rendered":"<p>Mwnci main functions are automatically loaded at application start.<\/p>\n<pre>include(\"main\")<\/pre>\n<h2>Functions<\/h2>\n<div class=\"table-wrap\">\n<table class=\"confluenceTable\">\n<tbody>\n<tr>\n<td class=\"confluenceTd\"><strong>Command<\/strong><\/td>\n<td class=\"confluenceTd\"><strong>Definition<\/strong><\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-bin2dec-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">bin2dec()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns a decimal number from the given binary number.<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-bsearch-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">bsearch()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns the index within an array of a given search <\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-contains-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">contains()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns <em>true<\/em> if a string contains the given word.<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-divmod-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">divmod()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns an array containing the quotient  and the remainder when argument1 (dividend) is divided by argument2 (divisor).<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-enumerate-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">enumerate()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns the contents of an array as a collection of array pairs, and adds a counter as the key of the enumerate array.<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-first-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">first()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Return the first element of an array..<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-getblock-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">getblock()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns an array of strings between and including the first string an second string from an array.<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-getenv-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">getenv()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns the value of the named environment variable.<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-getblock-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">getfileblock()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns an array of strings between and including the first string an second string from a file.<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-head-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">head()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns the designated amount if lines from a string, or first amount of elements from an array.<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-hex2dec-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">hex2dec()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns decimal equivalent of a hexadecimal string.<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-interpol-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">interpol()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns a string with tokenised names replaced by the hash token value.<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-intersect-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">intersect()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns an array that contains the items that exist in both array x, and array y.<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-isrsorted-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">isrsorted()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns <i>true<\/i> if the contents of an array are sorted in descending order.<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-issubset-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">issubset()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns <em>true<\/em> if all items in the first array exists in the second array.<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-last-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">last()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns the last element of an array.<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-lines-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">lines()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns the amount of lines in a string (where lines are separated by &#8220;\\n&#8221;).<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-lookupcname-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">lookupcname()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns the canonical name for the given host.<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-lookuphost-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">lookuphost()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns an array of the named host\u2019s addresses. <\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-lookupip-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">lookupip()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns an array of that host\u2019s IP addresses. <\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-lookupmx-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">lookupmx()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns the DNS MX records for the given domain name sorted by preference. <\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-lookupns-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">lookupns()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns an array of the name servers for the given host.<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-lookupptr-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">lookupptr()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns an array of domain names for a given IP address.<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-lookuptxt-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">lookuptxt()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns an array of the TXT records for the given host.<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-map-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">map()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Executes a specified function for each item in a string or array.<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-max-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">max()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns highest value within the named array.<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-min-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">min()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns lowest value within the named array.<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-oct2bin-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">oct2bin()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns binary string equivalent of an octal number.<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-oct2dec-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">oct2dec()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns decimal equivalent of an octal number.<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-oct2sym-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">oct2sym()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns symbolic notation of file permissions for the given octal number.<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-randwords-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">randwords()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns an array of the requested amount of random words from \/usr\/share\/dict\/words.\n<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-rest-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">rest()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns a new array with the first element of <em>array<\/em> removed.\n<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-rindex-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">rindex()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns the position of the search item (indicated as an integer) in a string or array.\n<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-rotl-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">rotl()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Rotates the items in a string or array to the left.\n<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-rotr-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">rotr()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Rotates the items in a string or array to the right.\n<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-sort-function-2\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">rsort()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns an array in reverse sorted order.\n<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-rsortips-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">rsortips()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns an array of IP addresses in descending order.\n<\/td>\n<\/tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-sortips-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">sortips()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns an array of IP address in ascending order.<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-tail-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">tail()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns the last designated amount of lines from a string, or last amount of elements from an array.\n<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-tr-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">tr()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns a string with character translation using the characters defined in the arguments.\n<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-tty-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">tty()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns the name of the terminal attached to standard input.\n<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-uptime-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">uptime()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns a hash of time values representing the amount of time the system has been running.\n<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\" colspan=\"1\"><a class=\"conf-macro output-inline\" href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-usort-function\/\" data-macro-name=\"sp-nobody-link\" data-hasbody=\"false\">usort()<\/a><\/td>\n<td class=\"confluenceTd\" colspan=\"1\">Returns a new array sorted in ascending order, with duplicates removed.\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Mwnci main functions are automatically loaded at application start. include(&#8220;main&#8221;) Functions Command Definition bin2dec() Returns a decimal number from the given binary number. bsearch() Returns the index within an array of a given search contains() Returns true if a string contains the given word. divmod() Returns an array containing the quotient and the remainder when &hellip; <a href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/included-main-functions\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Included Main Functions&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-526","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages\/526","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/comments?post=526"}],"version-history":[{"count":66,"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages\/526\/revisions"}],"predecessor-version":[{"id":1337,"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages\/526\/revisions\/1337"}],"wp:attachment":[{"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/media?parent=526"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}