{"id":564,"date":"2020-05-22T11:16:57","date_gmt":"2020-05-22T08:16:57","guid":{"rendered":"https:\/\/ek.oa.edu.ua\/Kukhta\/test3\/?p=564"},"modified":"2020-05-22T16:44:12","modified_gmt":"2020-05-22T13:44:12","slug":"perebir-elementiv-masyvu-v-php","status":"publish","type":"post","link":"https:\/\/ithub.oa.edu.ua\/webdev\/php\/perebir-elementiv-masyvu-v-php\/","title":{"rendered":"\u041f\u0435\u0440\u0435\u0431\u0456\u0440 \u0435\u043b\u0435\u043c\u0435\u043d\u0442\u0456\u0432 \u043c\u0430\u0441\u0438\u0432\u0443"},"content":{"rendered":"<p>\u041e\u043a\u0440\u0456\u043c \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u0430\u043d\u043d\u044f \u0446\u0438\u043a\u043b\u0443 <code>for<\/code> \u0434\u043b\u044f \u0432\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044f \u0443\u0441\u0456\u0445 \u0435\u043b\u0435\u043c\u0435\u043d\u0442\u0456\u0432 \u043c\u0430\u0441\u0438\u0432\u0443 \u043d\u0430 \u0435\u043a\u0440\u0430\u043d \u043c\u0438 \u043c\u043e\u0436\u0435\u043c\u043e \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u0430\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0456\u044e <code>print_r<\/code>, \u044f\u043a\u0430 \u0432\u0438\u0432\u0435\u0434\u0435 \u0443\u0441\u0456 \u0435\u043b\u0435\u043c\u0435\u043d\u0442\u0438 \u043c\u0430\u0441\u0438\u0432\u0443 \u0440\u0430\u0437\u043e\u043c \u0437 \u0457\u0445 \u0456\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438.<\/p>\n<pre class=\"prettyprint linenums\">&lt;?php\r\n<span class=\"hljs-variable\">$arr<\/span>[<span class=\"hljs-number\">0<\/span>] = <span class=\"hljs-string\">\"PHP\"<\/span>; \r\n<span class=\"hljs-variable\">$arr<\/span>[<span class=\"hljs-number\">1<\/span>] = <span class=\"hljs-string\">\"HTML\"<\/span>; \r\n<span class=\"hljs-variable\">$arr<\/span>[<span class=\"hljs-number\">2<\/span>] = <span class=\"hljs-string\">\"CSS\"<\/span>;\r\n\r\nprint_r(<span class=\"hljs-variable\">$arr<\/span>); \r\n?&gt;<\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u0431\u0440\u0443\u0437\u0435\u0440\u0456:<\/p>\n<pre class=\"result\">Array ( [0] =&gt; PHP [1] =&gt; HTML [2] =&gt; CSS )<\/pre>\n<p>\u0422\u0430\u043a\u043e\u0436, \u0449\u043e\u0431 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044f \u0444\u0443\u043d\u043a\u0446\u0456\u0457 <code>print_r<\/code> \u0431\u0443\u0432 \u043d\u0430\u043e\u0447\u043d\u0456\u0448\u0438\u043c, \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u0435\u0440\u0435\u0434 \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u0430\u043d\u043d\u044f\u043c \u0444\u0443\u043d\u043a\u0446\u0456\u0457 \u043f\u0438\u0441\u0430\u0442\u0438 <code>echo \"&lt;pre&gt;\";<\/code>, \u0430 \u043f\u0456\u0441\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0456\u0457 &#8211; <code>echo \"&lt;\/pre&gt;\";<\/code><abbr style=\"box-sizing: border-box; cursor: help; border-bottom: 1px dotted #b3b3b3; color: #3fad46; font-family: Roboto, Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;\" title=\"\" data-toggle=\"tooltip\" data-placement=\"top\" data-original-title=\"\u0415\u043b\u0435\u043c\u0435\u043d\u0442 &lt;pre&gt; \u0432\u0438\u0437\u043d\u0430\u0447\u0430\u0454 \u0431\u043b\u043e\u043a \u0437\u0430\u0437\u0434\u0430\u043b\u0435\u0433\u0456\u0434\u044c \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432\u0430\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0443. \u0422\u0430\u043a\u0438\u0439 \u0442\u0435\u043a\u0441\u0442 \u0432\u0456\u0434\u043e\u0431\u0440\u0430\u0436\u0430\u0454\u0442\u044c\u0441\u044f \u0437\u0430\u0437\u0432\u0438\u0447\u0430\u0439 \u0437 \u0443\u0441\u0456\u043c\u0430 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u043c\u0438 \u043c\u0456\u0436 \u0441\u043b\u043e\u0432\u0430\u043c\u0438.\"><strong><br \/>\n<\/strong><\/abbr><\/p>\n<p>\u0422\u0430\u043a\u043e\u0436 \u0432 PHP \u0454\u00a0 \u0441\u043f\u0435\u0446\u0456\u0430\u043b\u044c\u043d\u0438\u0439 \u0446\u0438\u043a\u043b \u0434\u043b\u044f \u043e\u0431\u0440\u043e\u0431\u043a\u0438 \u043c\u0430\u0441\u0438\u0432\u0456\u0432 &#8211; \u0446\u0438\u043a\u043b <code>foreach<\/code><\/p>\n<pre class=\"prettyprint linenums\">&lt;?php\r\n$arr[0] = \"PHP\"; \r\n$arr[1] = \"HTML\"; \r\n$arr[2] = \"CSS\";\r\n\r\n<span class=\"hljs-keyword\">foreach<\/span>(<span class=\"hljs-variable\">$arr<\/span> <span class=\"hljs-keyword\">as<\/span> <span class=\"hljs-variable\">$value<\/span>)\r\n{\r\n \u00a0 \u00a0  <span class=\"hljs-keyword\">echo<\/span> <span class=\"hljs-variable\">$value<\/span>, <span class=\"hljs-string\">\"&lt;br&gt;\"<\/span>;\r\n}\r\n<span class=\"hljs-preprocessor\">?&gt;<\/span><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0456:<\/p>\n<pre class=\"result\">PHP\r\nHTML\r\nCSS<\/pre>\n<p>\u0414\u043b\u044f \u0432\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044f \u0456\u043d\u0434\u0435\u043a\u0441\u0443 \u0435\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u0442\u0440\u0435\u0431\u0430 \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u0430\u0442\u0438 \u0434\u0440\u0443\u0433\u0438\u0439 \u0432\u0430\u0440\u0456\u0430\u043d\u0442 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0443 \u0446\u0438\u043a\u043b\u0443 <code>foreach<\/code><\/p>\n<pre class=\"prettyprint linenums\">&lt;?php\r\n$arr[0] = \"PHP\"; \r\n$arr[1] = \"HTML\"; \r\n$arr[2] = \"CSS\";\r\n\r\n<span class=\"hljs-keyword\">foreach<\/span>(<span class=\"hljs-variable\">$arr<\/span> <span class=\"hljs-keyword\">as<\/span> <span class=\"hljs-variable\">$key<\/span> =&gt; <span class=\"hljs-variable\">$value<\/span>) { <span class=\"hljs-comment\">\/\/ <\/span><strong><span class=\"hljs-comment\">$key<\/span><\/strong><span class=\"hljs-comment\"> - \u0456\u043d\u0434\u0435\u043a\u0441 \u0435\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043c\u0430\u0441\u0438\u0432\u0430, <\/span><strong><span class=\"hljs-comment\">$value<\/span><\/strong><span class=\"hljs-comment\"> - \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f \u0435\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043c\u0430\u0441\u0438\u0432\u0430\r\n<\/span>\u00a0 \u00a0  <span class=\"hljs-keyword\">echo<\/span> <span class=\"hljs-string\">\"[{$key}] =&gt; {$value} &lt;br\/&gt;\"<\/span>;\r\n}\r\n<span class=\"hljs-preprocessor\">?&gt;<\/span><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0456:<\/p>\n<pre class=\"result\">[0] =&gt; PHP\r\n[1] =&gt; HTML\r\n[2] =&gt; CSS<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u041e\u043a\u0440\u0456\u043c \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u0430\u043d\u043d\u044f \u0446\u0438\u043a\u043b\u0443 for \u0434\u043b\u044f \u0432\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044f \u0443\u0441\u0456\u0445 \u0435\u043b\u0435\u043c\u0435\u043d\u0442\u0456\u0432 \u043c\u0430\u0441\u0438\u0432\u0443 \u043d\u0430 \u0435\u043a\u0440\u0430\u043d \u043c\u0438 \u043c\u043e\u0436\u0435\u043c\u043e \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u0430\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0456\u044e print_r, \u044f\u043a\u0430 \u0432\u0438\u0432\u0435\u0434\u0435 \u0443\u0441\u0456 \u0435\u043b\u0435\u043c\u0435\u043d\u0442\u0438 \u043c\u0430\u0441\u0438\u0432\u0443 \u0440\u0430\u0437\u043e\u043c \u0437 \u0457\u0445 \u0456\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438. &lt;?php $arr[0] = &#8220;PHP&#8221;; $arr[1] = &#8220;HTML&#8221;; $arr[2] = &#8220;CSS&#8221;; print_r($arr); ?&gt; \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u0431\u0440\u0443\u0437\u0435\u0440\u0456: Array ( [0] =&gt; PHP [1] =&gt; HTML [2] =&gt; CSS ) \u0422\u0430\u043a\u043e\u0436, \u0449\u043e\u0431 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-564","post","type-post","status-publish","format-standard","hentry","category-massyvy"],"_links":{"self":[{"href":"https:\/\/ithub.oa.edu.ua\/webdev\/php\/wp-json\/wp\/v2\/posts\/564","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ithub.oa.edu.ua\/webdev\/php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ithub.oa.edu.ua\/webdev\/php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ithub.oa.edu.ua\/webdev\/php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ithub.oa.edu.ua\/webdev\/php\/wp-json\/wp\/v2\/comments?post=564"}],"version-history":[{"count":3,"href":"https:\/\/ithub.oa.edu.ua\/webdev\/php\/wp-json\/wp\/v2\/posts\/564\/revisions"}],"predecessor-version":[{"id":590,"href":"https:\/\/ithub.oa.edu.ua\/webdev\/php\/wp-json\/wp\/v2\/posts\/564\/revisions\/590"}],"wp:attachment":[{"href":"https:\/\/ithub.oa.edu.ua\/webdev\/php\/wp-json\/wp\/v2\/media?parent=564"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ithub.oa.edu.ua\/webdev\/php\/wp-json\/wp\/v2\/categories?post=564"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ithub.oa.edu.ua\/webdev\/php\/wp-json\/wp\/v2\/tags?post=564"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}