Welcome Guest, Not a member yet? Register   Sign In
How to create an array of objects??
#3

[eluser]gwelter[/eluser]
Code:
class myc
{
    var $i='dude';
    function pr(){echo 'hi '.$this->i.'<br>';}
}

$test = new myc;
$test->i='compadre';
$testtwo = new myc;
$testtwo->i = 'senor';

$arr = array($test, $testtwo);

$arr[0]->pr();
$arr[1]->pr();

foreach($arr AS $cl) { $cl->pr(); }

Output:

hi compadre
hi senor
hi compadre
hi senor

Works for me..?


Messages In This Thread
How to create an array of objects?? - by El Forum - 01-28-2011, 08:57 PM
How to create an array of objects?? - by El Forum - 01-29-2011, 12:06 AM
How to create an array of objects?? - by El Forum - 01-29-2011, 10:32 AM
How to create an array of objects?? - by El Forum - 01-29-2011, 10:35 AM
How to create an array of objects?? - by El Forum - 01-30-2011, 07:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB