{"id":772,"date":"2024-11-28T12:11:01","date_gmt":"2024-11-28T12:11:01","guid":{"rendered":"http:\/\/monkey.ploogie.co.uk\/?page_id=772"},"modified":"2024-11-29T08:07:41","modified_gmt":"2024-11-29T08:07:41","slug":"mwnci-substr-function","status":"publish","type":"page","link":"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-substr-function\/","title":{"rendered":"Mwnci substr() Function"},"content":{"rendered":"<h2>Syntax<\/h2>\n<p>substr<strong>(<em>string<\/em>, <em>integer<\/em>, <em>[integer]<\/em>)<\/strong><\/p>\n<h2>Description<\/h2>\n<p>The <i>substr()<\/i> function returns a substring of a given string indicated by the starting position and the substring length.<br \/>\nNote the index of a string is 0.  If the length requested is longer that the string, or is 0, the returned substring will default to the end of the string.<\/p>\n<h2>Example<\/h2>\n<pre>\r\na=\"foobar\"\r\nprintln(substr(a,1,2))\r\nprintln(\"->\",substr(a,3,1000),\"<-\")\r\nprintln(substr(a,3,1))\r\n\r\n\r\noo\r\n->bar<-\r\nb\r\n<\/pre>\n<p>It's also possible to git a negative index which counts back a given amount of characters<\/p>\n<pre>\r\na=\"foobar\"\r\nprintln(substr(a, -3))\r\nprintln(substr(a, -3, 2))\r\n\r\n\r\nbar\r\nba\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Syntax substr(string, integer, [integer]) Description The substr() function returns a substring of a given string indicated by the starting position and the substring length. Note the index of a string is 0. If the length requested is longer that the string, or is 0, the returned substring will default to the end of the string. &hellip; <a href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-substr-function\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Mwnci substr() Function&#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-772","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages\/772","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=772"}],"version-history":[{"count":6,"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages\/772\/revisions"}],"predecessor-version":[{"id":787,"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages\/772\/revisions\/787"}],"wp:attachment":[{"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/media?parent=772"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}