3064 Posts in 865 Topics by 647 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1254 Views |
-
How to access ArrayData values by another function ???

18 June 2010 at 11:30am
Probably very silly question but can get it done ...
function test() {
$values = new ArrayData(array(
'd1' => 'somedata',
'd2' => 'moredata',
));
return $values;
}function stuff() {
$a = $this->test();
$b = $a[d1].'added';
return $b;
}accessing data in arraydata as in regular array drops error?
thank for help .. -
Re: How to access ArrayData values by another function ???

18 June 2010 at 4:02pm
Well because you have a ArrayData object read the ArrayData API for what you can call on that object. getField($fieldname). Sounds like that you want to do. I think you can also use magic vars like $a->d1 to get the d1 or $a->getField('d1'); is the long option.
Ref: http://api.silverstripe.org/2.4/sapphire/view/ArrayData.html
-
Re: How to access ArrayData values by another function ???

18 June 2010 at 9:21pm
Thank Willr - works nicely
the things is I tried the getField but like this: $x = getField('d1',$a), yeah me stupid cant read API properly
thanks again .. have a nice day.
| 1254 Views | ||
|
Page:
1
|
Go to Top |


