Jump to content

Archived

This topic is now archived and is closed to further replies.

liamloveslearning

Assign array value to variable?

Recommended Posts

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...

Share this post


Link to post
Share on other sites

Yes:

 

$myArr = array("Hi", "I'm", "an", "array");

$an = $myArr[2];

echo $an;

Share this post


Link to post
Share on other sites

also if you wanted to show the entire array you would have

$myArr = array("Hi", "I'm", "an", "array");

$an = $myArr[];

print_r($an);

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.