<?php
header("Content-Type: text/html; charset=utf-8");
$arrayName = array("jsp","asp","php");
print_r($arrayName);
echo "<br>",$arrayName[1];
echo "<br>";
$array2 = array("1" => "電", "2" => "子","3" => "辞", "4" => "書");
print_r($array2);
?>
Array ( [0] => jsp [1] => asp [2] => php )
asp
Array ( [1] => 電 [2] => 子 [3] => 辞 [4] => 書 )
<?php
header("Content-Type: text/html; charset=utf-8");
$arrayName = array("first" => "1", "second" => "2","third" => "3");
print_r($arrayName);
echo "<br>";
$arrayName["third"]="8";
print_r($arrayName);
?>
Array ( [first] => 1 [second] => 2 [third] => 3 )
Array ( [first] => 1 [second] => 2 [third] => 8 )
<?php
header("Content-Type: text/html; charset=utf-8");
$arrayName = array(
"書類" => array("文学","歴史","地理"),
"体育物" => array("s" => "サッカー","b" => "バスケットボール"),
"果物" => array("オレンジ", "p" => "ブドウ","リンゴ"),
);
print_r($arrayName);
echo "<br>";
?>
Array ( [書類] => Array ( [0] => 文学 [1] => 歴史 [2] => 地理 ) [体育物] => Array ( [s] => サッカー [b] => バスケットボール ) [果物] => Array ( [0] => オレンジ [p] => ブドウ [1] => リンゴ ) )
<?php
header("Content-Type: text/html; charset=utf-8");
$arrayName = array(
"書類" => array("文学","歴史","地理"),
"体育物" => array("s" => "サッカー","b" => "バスケットボール"),
"果物" => array("オレンジ", "p" => "ブドウ","リンゴ"),
);
foreach ($arrayName as $key) {
print_r($key);
echo "<br>";
foreach ($key as $mono => $value) {
echo $value,"<br>";
}
echo "<br>";
}
?>
Array ( [0] => 文学 [1] => 歴史 [2] => 地理 )
文学
歴史
地理
Array ( [s] => サッカー [b] => バスケットボール )
サッカー
バスケットボール
Array ( [0] => オレンジ [p] => ブドウ [1] => リンゴ )
オレンジ
ブドウ
リンゴ
<?php
header("Content-Type: text/html; charset=utf-8");
$str="a,b,c";
$strs=explode(",", $str);
print_r($strs);
?>
Array ( [0] => a [1] => b [2] => c )