liamloveslearning Posted May 17, 2011 Share Posted May 17, 2011 Hi everybody, im reading up on arrays and im still stuck... Is it possible to assign an array to a variable? I need something like... &needvariable = $row->User Hopefully this makes sense... Link to comment https://forums.phpfreaks.com/topic/236674-assign-array-value-to-variable/ Share on other sites More sharing options...
KevinM1 Posted May 17, 2011 Share Posted May 17, 2011 Yes: $myArr = array("Hi", "I'm", "an", "array"); $an = $myArr[2]; echo $an; Link to comment https://forums.phpfreaks.com/topic/236674-assign-array-value-to-variable/#findComment-1216649 Share on other sites More sharing options...
fugix Posted May 17, 2011 Share Posted May 17, 2011 also if you wanted to show the entire array you would have $myArr = array("Hi", "I'm", "an", "array"); $an = $myArr[]; print_r($an); Link to comment https://forums.phpfreaks.com/topic/236674-assign-array-value-to-variable/#findComment-1216651 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.