TwistedBalloon Posted February 13, 2007 Share Posted February 13, 2007 Is there some way to do the following: I want to pick one array from a group of arrays and then access a value within it. All the arrays have similar names: $myarray1 $myarray2 etc. What I thought would be simple would be to append the appropriate digit to the end as needed to select the array I want to extract data from $desiredarray = '$myarray'.1; But when I echo out something like $desiredarray[0] I get a string, not the value of the array element I was trying to address. Anybody have any suggestions? Link to comment https://forums.phpfreaks.com/topic/38338-retrieving-array-elements-using-key-value-pairs-set-by-variables/ Share on other sites More sharing options...
genericnumber1 Posted February 13, 2007 Share Posted February 13, 2007 I'd really suggest using a multidimensional array but if not you can do it with messy code I really don't suggest doing it like this... $array = 'myarray1'; $desiredarray = $$array; Link to comment https://forums.phpfreaks.com/topic/38338-retrieving-array-elements-using-key-value-pairs-set-by-variables/#findComment-183774 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.