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