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 Quote 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 } Quote 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 Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.