This would work but it is bad design. See here why.
<?php
$list_a = array(); //defining an array
$list_b = array();
$list_c = array();
function addText($a,$b,$c)
{
global $list_a, $list_b, $list_c;
$list_a[] = $a;
$list_b[] = $b;
$list_c[] = $c;
}
function foreachThem()
{
global $list_a, $list_b, $list_c;
foreach($list_a as $item)
{
//...
}
foreach($list_b as $item)
{
//...
}
foreach($list_c as $item)
{
//...
}
}
A better way would be saving them in a parent array (this is optional but it reduces the amount of parameters and therefor the amount of code) and passing it as reference. See here for info on passing by reference.
<?php
$theLists = array(
"a" => array(),
"b" => array(),
"c" => array()
);
// note the '&'
function addText(&$lists, $a,$b,$c)
{
$lists["a"][] = $a;
$lists["b"][] = $b;
$lists["c"][] = $c;
}
// '&' is not needed here
function foreachThem($lists)
{
foreach($lists["a"] as $item)
{
//...
}
foreach($lists["b"] as $item)
{
//...
}
foreach($lists["c"] as $item)
{
//...
}
}