csplrj Posted January 3, 2010 Share Posted January 3, 2010 I want to call $addRecord->Documents[0]->name = 'a' but as "Documents" and "name" come from runtime I tried $addRecord->$docs[$i++]->$name = 'a' But it calls instead $addRecord->D->name = 'a' I want to call $addRecord->Documents[0]->name = 'a'. But instead it calls $addRecord->D->name = 'a'? How to achieve the same Thanks in advance CSJakharia Link to comment https://forums.phpfreaks.com/topic/187007-setting-some-array-values-dynamically-at-runtime/ Share on other sites More sharing options...
sasa Posted January 3, 2010 Share Posted January 3, 2010 <?php $addRecord->Documents[0]->name = 'a'; $doc = 'Documents'; $i = 0; $name = 'name'; echo $addRecord->{$doc}[$i]->{$name}; ?> add some { and } Link to comment https://forums.phpfreaks.com/topic/187007-setting-some-array-values-dynamically-at-runtime/#findComment-987584 Share on other sites More sharing options...
csplrj Posted January 3, 2010 Author Share Posted January 3, 2010 Thanks that works CSJakharia Link to comment https://forums.phpfreaks.com/topic/187007-setting-some-array-values-dynamically-at-runtime/#findComment-987636 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.