Arrays
An array is a way of storing multiple values in one place. For example:
['ehm', 'cubic', 'tehnodom', 'dg']
The syntax of an array is as follows: the beginning and end of the array are designated by square brackets, and all values, or array elements, are written inside these brackets and separated by commas.
An array can be written to a variable, just like strings and numbers.
$array_name = [element_1, element_2, element_3];
Indexes
All elements in the array have a serial number, i.e., an index. It allows you to access a specific element in the array.
$films = ['Iron Man', 'The Avengers', 'Thor', 'Ant-Man'];
<p><?= $films[0] ?></p> // Displays the following on the page: "Iron Man"
To access an array element, you must write the array name and the element index in square brackets. The numbering of elements in the array begins with zero.
Writing data to an array by index
Indexes allow you not only to obtain elements, but also to write new data to the array.
Add the following new element to the array $favorite_food:
$favorite_food = ['mashed potatoes', 'meatballs', 'borsch'];
$favorite_food[3] = 'dumplings';
muffin_log ($favorite_food[3]); // Outputs: "dumplings"
Change the value of an element that is already in the array:
$favorite_food = ['mashed potatoes', 'meatballs', 'borsch'];
muffin_log ($favorite_food[1]); // Outputs: "cutlets"
$favorite_food[1] = 'pancakes' ;
muffin_log ($favorite_food[1]); // Outputs: "pancakes"
The while loop
A loop is a statement that allows you to execute the same code more than once. Loops work great with arrays.
The while loop syntax is similar to the syntax used by conditional statements — it consists of the loop name, loop condition, and loop body. The actions specified in the loop body will be executed repeatedly until the condition becomes false.
while (loop condition) {
loop body
}$months = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
In order to output all values from this array to the console, use the while loop:
$index = 0; // Creates a counter
while ($index < 12) {
muffin.log($months[$index]); // Displays the element in the console
$index = $index + 1; // Increases the value of the counter
}
Each execution of a block of code in the loop body is called an iteration. The number of iterations must be finite. Otherwise, the loop would run for an infinite number of times, and the page would never finish loading.
To limit the number of iterations, we have created a counter variable: $index. With each iteration, the number in the $index will increase by one. As a result, the elements in the $months array (the numbers 1 to 12) are output sequentially to the console. When the counter value reaches 12, the condition will become false and the loop will stop working.
The while loop in the template
To embed a loop using while in a template, you need to designate the beginning and end of the loop. Then insert the condition, and in the loop body set the element index to increase with each iteration and each time a page markup action is performed.
<?php while (condition): ?>
<li><?= $array[$index] ?></li>
<?php $index = $index + 1 ?>
<?php endwhile;? >
The count command
The count command allows you to calculate the number of elements in the array, which is also known as the array length. To do this, you need to write a set of parentheses after count, and inside the parentheses indicate the name of the array. You can save the obtained value to a variable, which allows you to continue working with it.
$one_to_five = [1, 2, 3, 4, 5];
$number = count($one_to_five);
muffin_log($number); // Outputs: 5
You need to keep in mind that the count command counts the number of elements and not their indexes.
Associative arrays
An array that uses keys instead of indexes is called an associative array. Each key stores a value, and it behaves like a variable. The key name is written in single quotation marks. You need to use the characters => to assign a value to the key.
$spiderman = [
'name' => 'Peter', // 'Name' key, value: 'Peter'
'surname' => 'Parker' // 'Surname' key, value: 'Parker'
];
Both of the array elements from the example refer to Spiderman, so it is convenient not to store them separately as variables, but together in a single array. To get the value from such an array, you need to write the array name and then specify the key in square brackets.
muffin_log($spiderman['name']); // Outputs: "Peter"
muffin_log($spiderman['surname']); // Outputs: "Parker"
Nested arrays
Arrays may themselves contain other arrays. These arrays are called nested arrays.
$flowers = [
0 => [
'name' => 'Chamomile',
'cost' => 'free'
],
1 => [
'name' => 'Lily',
'cost' => 300
]
];
The foreach loop
Loop syntax:
foreach ($array as $variable) {
loop body
}
With each iteration, the next element in the array becomes the value of the variable. Elements are sorted in order from first to last. Therefore, we do not need to use indices. All we need is to reference the variable in the loop body.
The foreach loop in the template
To add this loop to the page markup, we need to write the beginning and end of it, and then we need to insert the page markup actions in the loop body.
$fruits = ['Orange', 'Apple', 'Banana'];
<?php foreach ($fruits as $fruit): ?>
<li><?= $fruit ?></li>
<?php endforeach;? >
// A list of fruits will appear on the page.
Loop conditions
Conditions can be written inside loops. In this case, it is checked whether the condition is true or false at each iteration of the loop. If true, then the actions specified in the condition body will be executed.
$items = ['Table', 'Window', 'Bed'];
<ul class='products-list'>
<?php foreach($items as $item): ?>
<?php if ($item === 'Table'): ?>
// Actions with the page markup
<?php endif; ?>
<?php endforeach; ?>
</ul>
For more information on conditions, see the “Conditions” chapter.
“Strict equality” comparison operator
The comparison operator === is frequently used. It is called strict equality, and it checks whether the values to the left and right are equal. If they are equal, then the condition is true.
$item === 'Table'
Continue
<!DOCTYPE html><html lang="en" class="no-js"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><script>var b=document.documentElement.classList;b.remove('no-js');if(!window.Promise||!window.sessionStorage||!!sessionStorage.getItem('muller.v2')){b.add('muller')}</script><link rel="dns-prefetch" href="https://assets.htmlacademy.org"><script async src="https://www.googletagmanager.com/gtag/js?id=G-MXPCRXM48C"></script><script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-MXPCRXM48C');
</script><script type="text/javascript">
(function(e,t){var n=e.amplitude||{_q:[],_iq:{}};var r=t.createElement("script")
;r.type="text/javascript"
;r.integrity="sha384-d/yhnowERvm+7eCU79T/bYjOiMmq4F11ElWYLmt0ktvYEVgqLDazh4+gW9CKMpYW"
;r.crossOrigin="anonymous";r.async=true
;r.src="https://cdn.amplitude.com/libs/amplitude-5.2.2-min.gz.js"
;r.onload=function(){if(!e.amplitude.runQueuedFunctions){
console.log("[Amplitude] Error: could not load SDK")}}
;var i=t.getElementsByTagName("script")[0];i.parentNode.insertBefore(r,i)
;function s(e,t){e.prototype[t]=function(){
this._q.push([t].concat(Array.prototype.slice.call(arguments,0)));return this}}
var o=function(){this._q=[];return this}
;var a=["add","append","clearAll","prepend","set","setOnce","unset"]
;for(var u=0;u<a.length;u++){s(o,a[u])}n.Identify=o;var c=function(){this._q=[]
;return this}
;var l=["setProductId","setQuantity","setPrice","setRevenueType","setEventProperties"]
;for(var p=0;p<l.length;p++){s(c,l[p])}n.Revenue=c
;var d=["init","logEvent","logRevenue","setUserId","setUserProperties","setOptOut","setVersionName","setDomain","setDeviceId","setGlobalUserProperties","identify","clearUserProperties","setGroup","logRevenueV2","regenerateDeviceId","groupIdentify","onInit","logEventWithTimestamp","logEventWithGroups","setSessionId","resetSessionId"]
;function v(e){function t(t){e[t]=function(){
e._q.push([t].concat(Array.prototype.slice.call(arguments,0)))}}
for(var n=0;n<d.length;n++){t(d[n])}}v(n);n.getInstance=function(e){
e=(!e||e.length===0?"$default_instance":e).toLowerCase()
;if(!n._iq.hasOwnProperty(e)){n._iq[e]={_q:[]};v(n._iq[e])}return n._iq[e]}
;e.amplitude=n})(window,document);
amplitude.getInstance().init("df11525b6880a3c5e2af14f9b6238408", null,{
includeUtm: true,
includeGclid: true,
includeReferrer: true,
deviceIdFromUrlParam: true
}, function (instance) {
window.amplitudeLoaded = true;
});
</script><link rel="stylesheet" href="https://assets.htmlacademy.org/css/core.v284.css"><link rel="stylesheet" href="https://assets.htmlacademy.org/css/profile.v236.css"><link rel="stylesheet" href="https://assets.htmlacademy.org/css/course.v246.css"><link rel="stylesheet" href="https://assets.htmlacademy.org/css/course-interface-light.v20.css"><link rel="stylesheet" href="https://assets.htmlacademy.org/css/course-interface-en.v2.css"><script src="https://assets.htmlacademy.org/js/sentry.js" data-sentry="3774884cc81746ed84c0ba7c5cd4ac7b" data-project="26" data-version="2"></script><link rel="stylesheet" href="/css/custom.css"><link rel="stylesheet" href="/css/cookies.css"><link rel="preload" as="script" href="https://assets.htmlacademy.org/js/general.v274.js"><title>Summary of “Arrays and loops in PHP: Part 1” — Arrays and loops in PHP — HTML Academy</title><meta name="csrf-token" content="39964caf322823086fca37a7326b9bd2a54"><meta property="og:type" content="website"><meta property="og:site_name" content="HTML Academy"><meta name="twitter:url" property="og:url" content="https://htmlacademy.org"><meta name="twitter:title" property="og:title" content="Interactive online courses HTML Academy"><meta name="twitter:description" property="og:description" content="Together we’ll learn how to work with real code, solve true-to-life problems, use cutting edge technologies. Minimum of boring theory and lots of practical tasks."><meta name="twitter:image" property="og:image" content="https://htmlacademy.org/og/htmlacademy.png"><meta name="twitter:card" content="summary_large_image"><link rel="canonical" href="https://htmlacademy.org/courses/php-basics/php-arrays-loops/summary"><meta name="theme-color" content="#2f358f"></head><body class="course-interface course-interface--light course-interface--full" data-base="/assets/courses/23/"><header class="page-header page-header--course"><div class="page-header__inner"><div class="page-header__top"><a class="page-header__logo" href="/" aria-label="HTML Academy Home"><img src="https://assets.htmlacademy.org/img/logo--small.svg?cs=1218aec0be4a5f23db79ad29a14e30f7f9fb9a25" width="24" height="36" alt="HTML Academy"></a><nav class="main-nav main-nav--mini" role="navigation"><div class="main-nav__course-nav"><a class="main-nav__course-item main-nav__course-button main-nav__course-button--prev" href="/courses/php-basics/php-arrays-loops/output-all-products">Outputting all products to the page</a><div class="main-nav__course-item main-nav__course-list main-nav__course-list--collapsed"><b class="main-nav__course-title">Arrays and loops in PHP</b><span class="main-nav__course-stat">16/16</span><div class="main-nav__course-contents"><a class="main-nav__course-contents-link" href="/courses/php-basics/php-arrays-loops">Back to the list of tasks</a><ul class="main-nav__course-contents-list"><li class="main-nav__course-contents-item"><a href="/courses/php-basics/php-arrays-loops/php-output-element">1. Outputting several elements to PHP</a></li><li class="main-nav__course-contents-item"><a href="/courses/php-basics/php-arrays-loops/php-arrays">2. What are arrays?</a></li><li class="main-nav__course-contents-item"><a href="/courses/php-basics/php-arrays-loops/array-elements-indexes">3. Indexes of the array elements</a></li><li class="main-nav__course-contents-item"><a href="/courses/php-basics/php-arrays-loops/add-array-element">4. Adding an element to the array by index</a></li><li class="main-nav__course-contents-item"><a href="/courses/php-basics/php-arrays-loops/php-while-loop">5. The while loop in PHP</a></li><li class="main-nav__course-contents-item"><a href="/courses/php-basics/php-arrays-loops/while-in-template">6. Embedding the while loop in the template</a></li><li class="main-nav__course-contents-item"><a href="/courses/php-basics/php-arrays-loops/php-count-command">7. Counting the number of elements in the array using the count command</a></li><li class="main-nav__course-contents-item"><a href="/courses/php-basics/php-arrays-loops/count-in-template">8. Adding count to the template</a></li><li class="main-nav__course-contents-item"><a href="/courses/php-basics/php-arrays-loops/output-element-id">9. Outputting elements from the array by id</a></li><li class="main-nav__course-contents-item"><a href="/courses/php-basics/php-arrays-loops/php-associative-array">10. The associative array in PHP</a></li><li class="main-nav__course-contents-item"><a href="/courses/php-basics/php-arrays-loops/php-foreach-loop">11. The foreach loop in PHP</a></li><li class="main-nav__course-contents-item"><a href="/courses/php-basics/php-arrays-loops/foreach-output-elements">12. Outputting array elements to the page using foreach</a></li><li class="main-nav__course-contents-item"><a href="/courses/php-basics/php-arrays-loops/include-database">13. Including databases</a></li><li class="main-nav__course-contents-item"><a href="/courses/php-basics/php-arrays-loops/php-filtering">14. Filtering products</a></li><li class="main-nav__course-contents-item"><a href="/courses/php-basics/php-arrays-loops/output-all-products">15. Outputting all products to the page</a></li><li class="main-nav__course-contents-item main-nav__course-contents-item--current"><a href="/courses/php-basics/php-arrays-loops/summary">16. Summary of “Arrays and loops in PHP: Part 1”</a></li></ul></div></div><a class="main-nav__course-item main-nav__course-button main-nav__course-button--next" href="/courses/php-basics/php-arrays-loops">List of tasks</a></div><ul class="main-nav__list main-nav__list--user main-nav__list--user-guest"><li class="main-nav__item" itemprop="name"><a class="main-nav__link" href="/signup?redirect_url=%2Fcourses%2Fphp-basics%2Fphp-arrays-loops%2Fsummary" title="Sign up" data-modal="open" data-value="register" itemprop="url"><span class="main-nav__icon" aria-hidden="true"><svg aria-hidden="true"><use xlink:href="/img/sprites/general.svg#user"></use></svg></span>Sign up</a></li><li class="main-nav__item main-nav__item--login" itemprop="name"><a class="main-nav__link" href="/login?redirect_url=%2Fcourses%2Fphp-basics%2Fphp-arrays-loops%2Fsummary" title="Log in" data-modal="open" data-value="login" itemprop="url"><span class="main-nav__icon" aria-hidden="true"><svg aria-hidden="true"><use xlink:href="/img/sprites/general.svg#login"></use></svg></span>Log in</a></li></ul></nav></div></div></header><main class="course-container"><div class="course-theory"><div class="course-theory__inner"><section class="course-theory__content"><h1 class="course-theory__content-heading course-theory__content-heading--synopsis">Summary of “Arrays and loops in PHP: Part 1”</h1><div class="course-theory__content-text"><h2>Arrays</h2><p>An array is a way of storing multiple values in one place. For example:</p><pre><code>['ehm', 'cubic', 'tehnodom', 'dg']</code></pre><p>The syntax of an array is as follows: the beginning and end of the array are designated by square brackets, and all values, or <i>array elements</i>, are written inside these brackets and separated by commas.</p><p>An array can be written to a variable, just like strings and numbers.</p><pre><code>$array_name = [element_1, element_2, element_3];</code></pre><h2>Indexes</h2><p>All elements in the array have a serial number, i.e., an <b>index</b>. It allows you to access a specific element in the array.</p><pre><code>$films = ['Iron Man', 'The Avengers', 'Thor', 'Ant-Man'];
<p><?= $films<mark>[0]</mark> ?></p> // Displays the following on the page: "Iron Man"</code></pre><p>To access an array element, you must write the array name and the element index in square brackets. The numbering of elements in the array begins with <i>zero</i>.</p><h2>Writing data to an array by index</h2><p>Indexes allow you not only to obtain elements, but also to write new data to the array.</p><p>Add the following new element to the array <code>$favorite_food</code>:</p><pre><code>$favorite_food = ['mashed potatoes', 'meatballs', 'borsch'];
<mark>$favorite_food[3] = 'dumplings'</mark>;
muffin_log ($favorite_food[3]); // Outputs: "dumplings"</code></pre><p>Change the value of an element that is already in the array:</p><pre><code>$favorite_food = ['mashed potatoes', 'meatballs', 'borsch'];
muffin_log ($favorite_food[1]); // Outputs: "cutlets"
<mark>$favorite_food[1] = 'pancakes' </mark> ;
muffin_log ($favorite_food[1]); // Outputs: "pancakes"</code></pre><h2>The while loop</h2><p>A loop is a statement that allows you to execute the same code more than once. Loops work great with arrays.</p><p>The <code>while</code> loop syntax is similar to the syntax used by conditional statements — it consists of the <i>loop name</i>, <i>loop condition</i>, and <i>loop body</i>. The actions specified in the loop body will be executed repeatedly until the condition becomes false.</p><pre><code>while (loop condition) {
loop body
}</code></pre><pre><code>$months = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];</code></pre><p>In order to output all values from this array to the console, use the <code>while</code> loop:</p><pre><code>$index = 0; // Creates a counter
while (<mark>$index < 12</mark>) {
muffin.log($months[$index]); // Displays the element in the console
<mark>$index = $index + 1;</mark> // Increases the value of the counter
}</code></pre><p>Each execution of a block of code in the loop body is called an <b>iteration</b>. The number of iterations must be finite. Otherwise, the loop would run for an infinite number of times, and the page would never finish loading.</p><p>To limit the number of iterations, we have created a counter variable: <code>$index</code>. With each iteration, the number in the <code>$index</code> will increase by one. As a result, the elements in the <code>$months</code> array (the numbers 1 to 12) are output sequentially to the console. When the counter value reaches 12, the condition will become false and the loop will stop working.</p><h2>The while loop in the template</h2><p>To embed a loop using while in a template, you need to designate the beginning and end of the loop. Then insert the condition, and in the loop body set the element index to increase with each iteration and each time a page markup action is performed.</p><pre><code><?php while (condition): ?>
<mark><li><?= $array[$index] ?></li></mark>
<?php $index = $index + 1 ?>
<?php endwhile;? ></code></pre><h2>The count command</h2><p>The <code>count</code> command allows you to calculate the number of elements in the array, which is also known as the <i>array length</i>. To do this, you need to write a set of parentheses after <code>count</code>, and inside the parentheses indicate the name of the array. You can save the obtained value to a variable, which allows you to continue working with it.</p><pre><code>$one_to_five = [1, 2, 3, 4, 5];
$number = <mark>count($one_to_five)</mark>;
muffin_log($number); // Outputs: 5</code></pre><p>You need to keep in mind that the <code>count</code> command counts the number of elements and not their indexes.</p><h2>Associative arrays</h2><p>An array that uses keys instead of indexes is called an <b>associative</b> array. Each key stores a value, and it behaves like a variable. The key name is written in single quotation marks. You need to use the characters <code>=></code> to assign a value to the key.</p><pre><code>$spiderman = [
'name' => 'Peter', // 'Name' key, value: 'Peter'
'surname' => 'Parker' // 'Surname' key, value: 'Parker'
];</code></pre><p>Both of the array elements from the example refer to Spiderman, so it is convenient not to store them separately as variables, but together in a single array. To get the value from such an array, you need to write the array name and then specify the key in square brackets.</p><pre><code>muffin_log($spiderman<mark>['name']</mark>); // Outputs: "Peter"
muffin_log($spiderman<mark>['surname']</mark>); // Outputs: "Parker"</code></pre><h2>Nested arrays</h2><p>Arrays may themselves contain other arrays. These arrays are called nested arrays.</p><pre><code>$flowers = [
0 => [
'name' => 'Chamomile',
'cost' => 'free'
],
1 => [
'name' => 'Lily',
'cost' => 300
]
];</code></pre><h2>The foreach loop</h2><p>Loop syntax:</p><pre><code>foreach (<mark>$array as $variable</mark>) {
loop body
}</code></pre><p>With each iteration, the next element in the array becomes the value of the variable. Elements are sorted in order from first to last. Therefore, we do not need to use indices. All we need is to reference the variable in the loop body.</p><h2>The foreach loop in the template</h2><p>To add this loop to the page markup, we need to write the beginning and end of it, and then we need to insert the page markup actions in the loop body.</p><pre><code>$fruits = ['Orange', 'Apple', 'Banana'];
<?php foreach (<mark>$fruits as $fruit</mark>): ?>
<li><mark><?= $fruit ?></mark></li>
<?php endforeach;? >
// A list of fruits will appear on the page.</code></pre><h2>Loop conditions</h2><p>Conditions can be written inside loops. In this case, it is checked whether the condition is true or false at each iteration of the loop. If true, then the actions specified in the condition body will be executed.</p><pre><code>$items = ['Table', 'Window', 'Bed'];
<ul class='products-list'>
<?php foreach($items as $item): ?>
<?php <mark>if ($item === 'Table')</mark>: ?>
// Actions with the page markup
<?php endif; ?>
<?php endforeach; ?>
</ul></code></pre><p>For more information on conditions, see the “<a href="/courses/php-basics/php-conditions/">Conditions</a>” chapter.</p><h2>“Strict equality” comparison operator</h2><p>The comparison operator <code>===</code> is frequently used. It is called <b>strict equality</b>, and it checks whether the values to the left and right are equal. If they are equal, then the condition is true.</p><pre><code>$item === 'Table'</code></pre><br><a class="button button--green button--large button--wide button--icon" href="/courses/php-basics/php-arrays-loops"><svg aria-hidden="true"><use xlink:href="/img/sprites/general.svg#icon-check-bold"></use></svg>
Continue
</a></div></section></div></div><script
src="https://assets.htmlacademy.org/scripts/courses-spa/htmlacademy-task.v43.js"
data-assets-path="https://assets.htmlacademy.org/scripts/courses-spa/"
data-task-type="theory"
data-lang="en"
></script><script>HtmlacademyTask.setup(function(){});</script></main><footer class="page-footer page-footer--tiny"><div class="page-footer__inner"><p><a href="/docs/cookies">Cookies</a> ∙
<a href="/docs/privacy">Privacy</a> ∙
<a href="/docs/agreement">License Agreement</a> ∙
<a href="/docs/about">About</a> ∙
<a href="/contacts">Contacts</a> ∙
© HTML Academy OÜ, 2019−2026
</p><div class="page-footer__financial"><img src="https://assets.htmlacademy.org/img/visa-white.svg?cs=96e54ec8c587db9d4b1d8d328ffd87c2ebfd9555" alt="VISA" title="VISA" width="35" height="35"><img src="https://assets.htmlacademy.org/img/mastercard-horizontal.v2.svg" alt="Mastercard" title="Mastercard" width="35" height="35"></div></div></footer><div class="modal"><div class="modal__inner"><div class="modal__wrapper js-login hidden"><button class="modal__close icon-close" type="button" title="Close" data-modal="close"></button><h4 class="modal__header">Log in</h4><ul class="modal__social"><li class="modal__social-link modal__social-link--fb"><a href="/login/fb?redirect_url=%2Fcourses%2Fphp-basics%2Fphp-arrays-loops%2Fsummary" rel="nofollow" title="Log in via Facebook"><svg aria-hidden="true"><use xlink:href="/img/sprites/general.svg#facebook"></use></svg></a></li><li class="modal__social-link modal__social-link--google"><a href="/login/google?redirect_url=%2Fcourses%2Fphp-basics%2Fphp-arrays-loops%2Fsummary" rel="nofollow" title="Log in via Google"><svg height="30" width="30" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><path fill="#ffffff" d="M457.732 216.625c2.628 14.041 4.063 28.743 4.063 44.098C461.796 380.688 381.481 466 260.204 466c-116.023 0-210-93.977-210-210s93.977-210 210-210c56.704 0 104.077 20.867 140.44 54.73l-59.204 59.197v-.135c-22.046-21.002-50-31.762-81.236-31.762-69.297 0-125.604 58.537-125.604 127.841 0 69.29 56.306 127.968 125.604 127.968 62.87 0 105.653-35.965 114.46-85.312h-114.46v-81.902h197.528z"/></svg></a></li></ul><div class="modal__or"><span>or</span></div><form class="modal__form form" action="/login?redirect_url=%2Fcourses%2Fphp-basics%2Fphp-arrays-loops%2Fsummary" autocomplete="off" method="post" data-submit="o"><input type="hidden" name="csrf_name" value="csrf69aed5511c1fa"><input type="hidden" name="csrf_value" value="189edd2ad424ed40ad9d8be6af26c828"><div class="form__group"><label class="sr-only" for="login-email">Email</label><input class="field field--text field--full-width" type="email" name="email" placeholder="Email" value="" id="login-email"></div><div class="form__group"><label class="sr-only" for="login-password">Password</label><input class="field field--text field--full-width ym-disable-keys" type="password" name="password" placeholder="Password" id="login-password"></div><input class="button button--full-width" type="submit" data-submit-text="Logging in…" value="Log in"></form><p class="modal__forgot-password"><a href="/recover" data-modal="open" data-value="recover">Forgot your password?</a></p><a class="modal__bottom-link" href="/signup" data-modal="open" data-value="register">Sign up</a></div><div class="modal__wrapper js-register hidden"><button class="modal__close icon-close" type="button" title="Close" data-modal="close"></button><h4 class="modal__header">Sign up</h4><ul class="modal__social"><li class="modal__social-link modal__social-link--fb"><a href="/login/fb?redirect_url=%2Fcourses%2Fphp-basics%2Fphp-arrays-loops%2Fsummary" rel="nofollow" title="Log in via Facebook"><svg aria-hidden="true"><use xlink:href="/img/sprites/general.svg#facebook"></use></svg></a></li><li class="modal__social-link modal__social-link--google"><a href="/login/google?redirect_url=%2Fcourses%2Fphp-basics%2Fphp-arrays-loops%2Fsummary" rel="nofollow" title="Log in via Google"><svg height="30" width="30" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><path fill="#ffffff" d="M457.732 216.625c2.628 14.041 4.063 28.743 4.063 44.098C461.796 380.688 381.481 466 260.204 466c-116.023 0-210-93.977-210-210s93.977-210 210-210c56.704 0 104.077 20.867 140.44 54.73l-59.204 59.197v-.135c-22.046-21.002-50-31.762-81.236-31.762-69.297 0-125.604 58.537-125.604 127.841 0 69.29 56.306 127.968 125.604 127.968 62.87 0 105.653-35.965 114.46-85.312h-114.46v-81.902h197.528z"/></svg></a></li></ul><div class="modal__or"><span>or</span></div><form class="modal__form form" action="/signup?redirect_url=%2Fcourses%2Fphp-basics%2Fphp-arrays-loops%2Fsummary" autocomplete="off" method="post"><input type="hidden" name="csrf_name" value="csrf69aed5511c1fa"><input type="hidden" name="csrf_value" value="189edd2ad424ed40ad9d8be6af26c828"><div class="form__group"><label class="sr-only" for="email">
Email
<span class="required"><span class="sr-only">Required field</span><span class="required__star">*</span></span></label><div class="form__group-fields"><input class="field field--text field--full-width" type="email" name="email" value="" id="email" required placeholder="Email"></div></div><div class="form__group"><label class="sr-only" for="password">
Password
<span class="required"><span class="sr-only">Required field</span><span class="required__star">*</span></span></label><div class="form__group-fields"><input class="field field--text field--full-width" type="password" name="password" value="" id="password" required placeholder="Password"></div></div><div class="form__group"><label class="checkbox"><input class="checkbox__input" type="checkbox" name="agreement" value="1" required><span class="checkbox__text"><span>By signing up, you agree to our <a href="/docs/agreement" target="_blank">License Agreement</a> and <a href="/docs/privacy" target="_blank">Privacy Policy</a>.</span></span></label></div><input class="button button--full-width" type="submit" data-submit-text="Signing up…" value="Sign up"></form><a class="modal__bottom-link" href="/login?redirect_url=%2Fcourses%2Fphp-basics%2Fphp-arrays-loops%2Fsummary" data-modal="open" data-value="login">Log in</a></div><div class="modal__wrapper modal__wrapper--no-btn-bottom js-recover hidden"><button class="modal__close icon-close" type="button" title="Close" data-modal="close"></button><h4 class="modal__header">Restore access</h4><p class="modal__text-accent">Have you forgotten your password or lost access to your profile? Enter your email connected to your profile and we will send you a link to restore access.</p><form class="modal__form form" action="/recover" autocomplete="off" method="post" data-submit="o"><input type="hidden" name="csrf_name" value="csrf69aed5511c1fa"><input type="hidden" name="csrf_value" value="189edd2ad424ed40ad9d8be6af26c828"><div class="form__group"><label class="sr-only" for="recovery-email">Email</label><input class="field field--text field--full-width" type="email" name="email" placeholder="Email" value="" id="recovery-email"></div><script src='https://www.google.com/recaptcha/api.js'></script><div class="form__group"><div class="g-recaptcha" data-sitekey="6LetCTEqAAAAANROWtPzfC7Rfg9iIRiRt2k2FPn7"></div></div><input class="button button--full-width" type="submit" data-submit-text="Sending…" value="Send"></form><p class="modal__text">Forgot to connect your email to the profile? Email us and we’ll help.</p></div></div></div><script async src="https://assets.htmlacademy.org/js/general.v274.js" data-assets="https://assets.htmlacademy.org" data-require="toggle,navigation-courses,modal,form,nav"></script></body></html>