{"id":10865,"date":"2022-06-08T20:44:23","date_gmt":"2022-06-08T17:44:23","guid":{"rendered":"https:\/\/elzero.org\/?p=10865"},"modified":"2022-08-07T07:54:28","modified_gmt":"2022-08-07T04:54:28","slug":"php-implement-string-repeat-function","status":"publish","type":"post","link":"https:\/\/elzero.org\/old\/php-implement-string-repeat-function\/","title":{"rendered":"Implement String Repeat Function"},"content":{"rendered":"<h3>\u0645\u062d\u062a\u0648\u0649 \u0627\u0644\u062f\u0631\u0633<\/h3>\r\n\r\n<script type=\"text\/plain\" class=\"language-php\">\r\n<?php\r\n\r\n  \/*\r\n    Function Accept 3 Parameters\r\n    $str = The String To Repeat [Mandatory]\r\n    $repeats = Repeats Count [Optional] Default = 2\r\n    $space = Space Between Repeated String [Optional] Default = \"\"\r\n    --- Accept Any True Value [\"Space\", \"S\", \"s\", 1, true]\r\n  *\/\r\n\r\n  function elzero_string_repeat(string $str, int $repeats = 2, bool $space = false) {\r\n\r\n    $result = \"\";\r\n    $separator = $space ? \" \" : \"\";\r\n\r\n    \/\/ if ($space === true) {\r\n    \/\/   $separator = \" \";\r\n    \/\/ } else {\r\n    \/\/   $separator = \"\";\r\n    \/\/ }\r\n\r\n    for ($i = 0; $i < $repeats; $i++) :\r\n      $result .= $str . $separator;\r\n    endfor;\r\n    return $result;\r\n  }\r\n\r\n  echo elzero_string_repeat(\"Elzero\") . \"<br>\";\r\n  echo elzero_string_repeat(\"Elzero\", 2) . \"<br>\";\r\n  echo elzero_string_repeat(\"Elzero\", 3) . \"<br>\";\r\n  echo elzero_string_repeat(\"Elzero\", 3, \"S\") . \"<br>\";\r\n  echo elzero_string_repeat(\"Elzero\", 3, \"Space\") . \"<br>\";\r\n  echo elzero_string_repeat(\"Elzero\", 3, 1) . \"<br>\";\r\n<\/script>","protected":false},"excerpt":{"rendered":"<p>\u0645\u062d\u062a\u0648\u0649 \u0627\u0644\u062f\u0631\u0633<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1156],"tags":[],"class_list":["post-10865","post","type-post","status-publish","format-standard","hentry","category-functions-implement"],"_links":{"self":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/10865","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/comments?post=10865"}],"version-history":[{"count":2,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/10865\/revisions"}],"predecessor-version":[{"id":11694,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/10865\/revisions\/11694"}],"wp:attachment":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/media?parent=10865"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/categories?post=10865"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/tags?post=10865"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}