yes, it was only a shourtcut
Code: Select all
<?php
function printRowArray($arr)
{
foreach($arr as $key=>$value)
echo $key, '=>', $value, "<br />\n";
}
function getRowAsArray()
{
return array(1, 2, 3, 4, 5);
}
$row = getRowAsArray();
// <- something else here, maybe something like
$row['the'] = 'end';
// ->
printRowArray($row);
?>
---
but to answer your first question (now that there's hopefully no need anymore)
Code: Select all
<?php
function funcA()
{
global $myArray;
echo count($myArray), ' - ', count($GLOBALS['gArray']);
}
function funcB()
{
global $myArray; // either mark it as global
$myArray = array(1, 2, 3, 4, 5);
$GLOBALS['gArray'] = array(1, 2, 3, 4); // or use this superglobal array
}
funcB();
funcA();
?>
But try to avoid globals if it can be done as return value. This might be a personal preference but global variables are what I'd call side-effects...