jajtiii Posted July 5, 2012 Share Posted July 5, 2012 When trying to use a var var in an object, I keep getting the following error: Fatal error: Cannot use string offset as an array in C:\Web\apache\www\banookie_cms\plugins\bee_hives\modules\admin.mod.php on line 379 Recap: The following variables resolves as follows: $data_set resolves to inspection_new_data $i_id resolves to 308 $myHives->inspection_new_data['unmarked'][308] resolves to 1 But, the following variations generate the error above: $queen_opt = "{$myHives->$data_set['unmarked'][$i_id]}"; $queen_opt = $myHives->$data_set['unmarked'][$i_id]; Any guidance will be appreciated. Jones Quote Link to comment https://forums.phpfreaks.com/topic/265236-using-a-variable-variable-in-an-object/ Share on other sites More sharing options...
Barand Posted July 5, 2012 Share Posted July 5, 2012 try $queen_opt = $myHives->{$data_set}['unmarked'][$i_id]; Quote Link to comment https://forums.phpfreaks.com/topic/265236-using-a-variable-variable-in-an-object/#findComment-1359284 Share on other sites More sharing options...
jajtiii Posted July 5, 2012 Author Share Posted July 5, 2012 You rock. Many, many thanks. Worked perfectly. Quote Link to comment https://forums.phpfreaks.com/topic/265236-using-a-variable-variable-in-an-object/#findComment-1359465 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.