Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

push function 4

Status
Not open for further replies.

oinky

Programmer
Oct 29, 2001
45
US
Does any1 know what this actually does?

push (@$foo, $bar);

what exactly is @$foo ?

thx for the help.
 
@$foo?

if you set $foo to a string,

$foo = 'cars';

then you can use $foo to name an array,
@$foo

This array is @cars

HTH If you are new to Tek-Tips, please use descriptive titles, check the FAQs,
and beware the evil typo.
 
o wow never knew that thanks.
 
What goBoating described is a 'symbolic reference' in that, since $foo was not a reference (he actually defined it as 'cars') it was taken to become the actual name of the array: @$foo is the same as @cars

However, if $foo was a reference (to a possibly anonymous array) it could've been defined as:

$foo = ['this','that','other'];

and
@foo or @cars or any other incarnation wouldn't exist. In order to access those array elements, you would have to use the reference to them: $foo

This could be accomplished in many ways:

$foo->[0];
@{$foo}[0];
@$foo[0]


They all mean the same thing. So it's possible that this is a hard reference (rather than a symbolic reference) to an array, having a value (contents of $foo) appended to the end of it.

By the way that's what the push() function does, it pushes a value onto the end of an array. I figure that's not the brunt of your question though.

Hope this helps,

--Jim
 
Typo: In second to last paragraph I wrote (contents of $foo) and I should have said (contents if $bar)

Sorry.

--Jim
 
lol heheh nice speeeeeling
thx for the great help tho
8)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top