{"id":849,"date":"2020-04-19T15:53:51","date_gmt":"2020-04-19T14:53:51","guid":{"rendered":"https:\/\/blog.pgregg.com\/blog\/?p=849"},"modified":"2020-04-19T15:53:54","modified_gmt":"2020-04-19T14:53:54","slug":"legacy-php-str_split-function","status":"publish","type":"post","link":"https:\/\/blog.pgregg.com\/blog\/2020\/04\/legacy-php-str_split-function\/","title":{"rendered":"Legacy PHP: str_split function"},"content":{"rendered":"\n<p>This stems from 2003 when str_split() did not exist in PHP and was just being added. It showed how to implement a compatible function if your host didn&#8217;t have a newer version of PHP.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\/*\n * split a string up into equal sized chunks\n *\n * Paul Gregg &lt;pgregg@pgregg.com>\n * 23 September 2003\n *\n * Open Source Code:   If you use this code on your site for public\n * access (i.e. on the Internet) then you must attribute the author and\n * source web site: http:\/\/www.pgregg.com\/projects\/php\/code\/str_split.phps\n * str_split is available from PHP version 5 by default\n *\n *\/\n\n\nif (!function_exists('str_split')) {\n  Function str_split($string, $chunksize=1) {\n    preg_match_all('\/('.str_repeat('.', $chunksize).')\/Us', $string, $matches);\n    return $matches&#91;1];\n  }\n}\n>?<\/code><\/pre>\n\n\n\n<p><a href=\"https:\/\/pgregg.com\/projects\/php\/code\/str_split.phps\">Source code can be found here<\/a>.<\/p>\n\n\n\n<p><em><span class=\"has-inline-color has-vivid-red-color\">Note: This page is legacy &#8211; you won&#8217;t ever use this now. PHP has had str_split() for 15 years.<\/span><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This stems from 2003 when str_split() did not exist in PHP and was just being added. It showed how to implement a compatible function if your host didn&#8217;t have a newer version of PHP. Source code can be found here. Note: This page is legacy &#8211; you won&#8217;t ever use this now. PHP has had &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.pgregg.com\/blog\/2020\/04\/legacy-php-str_split-function\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Legacy PHP: str_split function&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-849","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pbQOUu-dH","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/posts\/849","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/comments?post=849"}],"version-history":[{"count":1,"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/posts\/849\/revisions"}],"predecessor-version":[{"id":850,"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/posts\/849\/revisions\/850"}],"wp:attachment":[{"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/media?parent=849"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/categories?post=849"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.pgregg.com\/blog\/wp-json\/wp\/v2\/tags?post=849"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}