snoodle
07-26-2007, 06:24 PM
having a bad morning... just trying to pass back a simple array of sql id's...
<?php
THIS DOES NOT WORK...
function GetArray()
{
for ($i=0; $i < 3; $i++)
{
...
$id= mysql_insert_id();
$array[$i] = $id;
}
return $array;
}
.....
$myIDs = GetArray();
echo "firstID=".$myID[0]; displays firstID=
THIS, TOO, DOES NOT WORK...
function GetArray()
{
$ids = Array();
for ($i=0; $i < 3; $i++)
{
...
$id= mysql_insert_id();
$ids[$i] = $id;
}
return $ids ;
}
.....
$myIDs = GetArray();
echo "firstID=".$myID[0]; displays firstID=
?>
------------------------------------
Looking through my code I realize that I haven't yet had ocassion to pass arrays to/from functions. Examples I've look at online and in my PHP book look like the above, but when I check the return values I get zilch. I've also tried passing the array in as an argument but am getting the same thing.
----------------------------------------
weird... even if i make the array a global i have the same problem.... what am i doing wrong? if i fill the array in a function... then examine the values in another function, i just get nulls when i examine the array contents.
<?php
THIS DOES NOT WORK...
function GetArray()
{
for ($i=0; $i < 3; $i++)
{
...
$id= mysql_insert_id();
$array[$i] = $id;
}
return $array;
}
.....
$myIDs = GetArray();
echo "firstID=".$myID[0]; displays firstID=
THIS, TOO, DOES NOT WORK...
function GetArray()
{
$ids = Array();
for ($i=0; $i < 3; $i++)
{
...
$id= mysql_insert_id();
$ids[$i] = $id;
}
return $ids ;
}
.....
$myIDs = GetArray();
echo "firstID=".$myID[0]; displays firstID=
?>
------------------------------------
Looking through my code I realize that I haven't yet had ocassion to pass arrays to/from functions. Examples I've look at online and in my PHP book look like the above, but when I check the return values I get zilch. I've also tried passing the array in as an argument but am getting the same thing.
----------------------------------------
weird... even if i make the array a global i have the same problem.... what am i doing wrong? if i fill the array in a function... then examine the values in another function, i just get nulls when i examine the array contents.