passing arrays from one function to an other
Posted: Thu Jul 03, 2003 5:52 pm
Hi There,
I was curious if you can pass an array as a global? It would make things allot easier for me. Ive had no trouble passing the $count variable as a global, but I just cant seem to figure out how to pass these arrays.
Sincerely,
Lambert the old
I was curious if you can pass an array as a global? It would make things allot easier for me. Ive had no trouble passing the $count variable as a global, but I just cant seem to figure out how to pass these arrays.
Sincerely,
Lambert the old
Code: Select all
<?php
function show_booked()
{
$query = "SELECT reservation_date FROM unit_availability WHERE unit_id = 240";
$result = mysql_query($query);
if (!$result)
{
error_message(sql_error());
}
$count = 0;
while ($row = mysql_fetch_array($result))
{
$booked = $row['reservation_date'];
//get dates year month and day
$a1[$count] = intval(substr($booked,0,4));
$m1[$count] = intval(substr($booked,5,3));
$d1[$count] = intval(substr($booked,8,3));
$month_length = strlen($m1[$count]);
$day_length = strlen($d1[$count]);
if($month_length==1)
{
$m1[$count] = "0".$m1[$count];
}
if($day_length==1)
{
$d1[$count] = "0".$d1[$count];
}
$count++;
}
}
class MyCalendar extends Calendar
{
function getDateLink($day, $month, $year)
{
global $count,$a1,$d1,$m1;
echo "*$a1*";
$link = "";
$i=0;
while($i<=$count)
{
if ($day == $d1[$count])
{
$link = "view_units.php";
}
return $link;
$count++;
$i++;
}
}
}
?>