Forum Moderators: coopster
for ($i=0;$i<10;$i++){
//new variable should have the name of the contents of $i
}
so i would end up with 10 variables e.g. $1,$2,$3,$4,$5,$6,$7,$8,$9,$10
is there a method available that does not use eval()
thanks guys.
for ($i=0;$i<10;$i++){
//new variable should have the name of the contents of $i
$myArray[$i] = 'contents';
}
So you can now loop through, or reference contents by value, in the same way as you would with numbered variable names.
F.
function instantiate_event($db_row_event,$posterdetails,$name){
$$name = new event(
$db_row_event['posteddate'],
$db_row_event['eventdate'],
$db_row_event['eventtitle'],
$db_row_event['eventdescription'],
$db_row_event['disabled'],
$db_row_event['admindisabled'],
$db_row_event['postedbyaccid'],
$db_row_event['memidofmemorial'],
$db_row_event['uniqueeventid'],
$posterdetails['firstname']);
return $$name;
}
//where it instantiates an event and places it in the events array
for ($i=0;$i<10;$i++){
$name = $i
events['$i'] = $this->instantiate_event($db_row_event,$posterdetails,$name);
}
is there a better way to do this?
is there a way to store an object in an array. where the array index is used to reference the object stored in it.