array(
key => value,
key2 => value2,
key3 => value3,
...
)
$chessboard [1] [4] = "King"; // Двухмерный массив
$capitals["USA"] ["Ohio"] = "Columbus": // Двухмерный массив
$streets["USA"]["Ohio"]["Columbus"] = "Harrison"; // Трехмерный массив
<?php
for ($i = 1; $i <= count($arr); $i++)
{
echo $arr[$i]." ";
}
?>
<?php
$arr[0] = "PHP";
$arr[1] = "HTML";
$arr[2] = "CSS";
print_r($arr);
?>
Array ( [0] => PHP [1] => HTML [2] => CSS )
foreach (array as $value) statement
foreach (array as $key => $value) statement
<?php
$arr[0] = "PHP";
$arr[1] = "HTML";
$arr[2] = "CSS";
foreach($arr as $value)
{
echo $value, "<br>";
}
?>
<?php
$arr = file("text.txt");
for($i = 0; $i < count($arr); $i++)
{
echo $arr[$i]."<br />";
}
?>
<?php
$str = "654|mail@mail.ru|http://www.it-black.ru|login|password";
$arr = explode("|",$str);
for($i = 0; $i < count($arr); $i++)
{
echo $arr[$i]."<br />";
}
?>
654
mail@mail.ru
https://www.it-black.ru
login
password
<?php
$arr[] = "654";
$arr[] = "mail@mail.ru";
$arr[] = "https://www.it-black.ru";
$arr[] = "login";
$arr[] = "password";
$str = implode("##",$arr);
echo $str; //654##mail@mail.ru##http://www.it-black.ru##login##password
?>
<?php
$arr = array(9, 8, 7, 6, 5, 4, 3, 2, 1, 0);
unset($arr);
if(isset($arr)) echo "Массив определён";
else echo "Массив не определён";
?>
<?php
echo 'параметры сервера:' . "<br />\n";
echo "Операционная система: " .
$_SERVER["OS"] . "<br />\n";
echo "Web-сервер: " .
$_SERVER["SERVER_SOFTWARE"] . "<br />\n";
echo "Имя сервера: " .
$_SERVER["SERVER_NAME"] . "<br />\n";
echo "Адрес сервера: " .
$_SERVER["SERVER_ADDR"] . "<br />\n";
echo "Порт сервера: " .
$_SERVER["SERVER_PORT"] . "<br />\n";
echo "Адрес клиента: " .
$_SERVER["REMOTE_ADDR"] . "<br />\n";
echo "Путь к документам на сервере: " .
$_SERVER["DOCUMENT_ROOT"] . "<br />\n";
echo "Полный путь к текущему скрипту: " .
$_SERVER["SCRIPT_FILENAME"] . "<br />\n";
echo "Имя текущего скрипта: " .
$_SERVER["PHP_SELF"] . "<br />\n";
?>