nimzie Posted February 18, 2010 Share Posted February 18, 2010 Hi, I'm trying to add a value to $node->field_spaces[x]['nid'] where x is the next available spot in the field_spaces array. Always adding to the next spot. I'll be calling this in a for loop to add things in there... Can anyone offer a hand? $node->field_spaces (array) $node->field_spaces[0] (array) $node->field_spaces[0]['nid'] Thank you, adam Link to comment https://forums.phpfreaks.com/topic/192539-adding-to-the-next-element-in-a-multidimensional-array/ Share on other sites More sharing options...
schilly Posted February 18, 2010 Share Posted February 18, 2010 you mean like node->field_spaces[0][] = $nid; Link to comment https://forums.phpfreaks.com/topic/192539-adding-to-the-next-element-in-a-multidimensional-array/#findComment-1014457 Share on other sites More sharing options...
nimzie Posted February 18, 2010 Author Share Posted February 18, 2010 I think what it has to do as it loops through the values to add is something like $node->field_spaces[0]['nid'] = $nid; $node->field_spaces[1]['nid'] = $nid; $node->field_spaces[2]['nid'] = $nid; $node->field_spaces[3]['nid'] = $nid; automatically as I iterate through things.... thank you for any help. cheers, adam Link to comment https://forums.phpfreaks.com/topic/192539-adding-to-the-next-element-in-a-multidimensional-array/#findComment-1014465 Share on other sites More sharing options...
schilly Posted February 18, 2010 Share Posted February 18, 2010 Ok. node->field_spaces[] = array('nid' => $nid); I think that should do it. Link to comment https://forums.phpfreaks.com/topic/192539-adding-to-the-next-element-in-a-multidimensional-array/#findComment-1014466 Share on other sites More sharing options...
nimzie Posted February 18, 2010 Author Share Posted February 18, 2010 thank you kindly for your help. Link to comment https://forums.phpfreaks.com/topic/192539-adding-to-the-next-element-in-a-multidimensional-array/#findComment-1014474 Share on other sites More sharing options...
schilly Posted February 18, 2010 Share Posted February 18, 2010 np Link to comment https://forums.phpfreaks.com/topic/192539-adding-to-the-next-element-in-a-multidimensional-array/#findComment-1014478 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.