Code: Select all
$sections = array('Section 1' => array('something', 'something'), 'Section 2' => array('something', 'something'), 'Section 3' => array('something', 'something'));Code: Select all
function getSection1() {
return $sections['Section 1'];
}
function getSection2() {
return $sections['Section 2'];
}
function getSection3() {
return $sections['Section 3'];
}Code: Select all
$sec1 = getSection1();
$sec2 = getSection2();
$sec3 = getSection3();but if I do this:
Code: Select all
$sec1 = $sections['Section 1'];
$sec2 = $sections['Section 2'];
$sec3 = $sections['Section 3'];Why doesn't it work if I return an array from functions, but it works if I access the $sections array directly?