기본적인 사용
$class = Array("hello", "world");
$class1 = ["Hello", "World"];
echo $class[0]; //hello
echo $class1[0]; //Hello
function hello(){
return ['hello', 'world'];
}
$tmp = hello();
echo $tmp[1]; //world
//더 쉽게.
echo hello()[1]; //world - php 5.4 이후버전부터 사용 가능
반복문 사용
function uit(){
return ['a', 'b', 'c', 'd', 'e', 'f'];
}
$members = uit();
for($i = 0; $i < count($members); $i++){
// Uppercase first
echo ucfirst($members[$i]).'<br />';
}
foreach 사용
//연관배열
$grades = array('conative'=>100, 'kyj'=>80, 'hw'=>35);
//열거
foreach($grades as $key => $value){
echo "key: {$key} value: {$value} <br />";
}