Re: dynamic/multidimensional arrays in classes
| From: | Patrick Teague | Date: | Fri, 28 Mar 2003 06:11:23 +0000 |
| Subject: | Re: dynamic/multidimensional arrays in classes | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-141380@lists.php.net to get a copy of this message | ||
I'm currently having a problem with another array in a class & I can't
figure it out -
class myClass
{
function myClass($arr = array(
'item1'=>array('a','b','c'),
'item2'=>array('a','b','c') ) )
{
print_r( $arr );
while( list($key,$val) = each($arr) )
{
print($key."=".$val);
}
}
}
now, if I say
$mine = myClass();
it only prints the print_r statement, but not the print($key."=".$val)
statment meaning it doesn't even bother entering the loop. However if I say
$mine = myClass(array( 'item1'=>array('a','b','c'),
'item2'=>array('a','b','c') ) );
it prints both... is there some reason why I need to repeat the default
value when creating the class? I've also tried using a "" string on class
creation, but no luck there either.
Patrick