FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » What is the purpose of "&" in this code?
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
What is the purpose of "&" in this code? [message #186110] Sat, 14 June 2014 15:08 Go to next message
Mr Oldies is currently offline  Mr Oldies
Messages: 241
Registered: October 2013
Karma: 0
Senior Member
foreach($master as &$ma)
$tmp[] = &$ma["date"];
array_multisort($tmp, $master);
foreach($master as &$ma)
echo $ma["date"]."<br/>";
Re: What is the purpose of "&" in this code? [message #186111 is a reply to message #186110] Sat, 14 June 2014 15:57 Go to previous messageGo to next message
Christoph Michael Bec is currently offline  Christoph Michael Bec
Messages: 207
Registered: June 2013
Karma: 0
Senior Member
richard wrote:

> foreach($master as &$ma)
> $tmp[] = &$ma["date"];
> array_multisort($tmp, $master);
> foreach($master as &$ma)
> echo $ma["date"]."<br/>";

See <http://www.php.net/manual/en/language.references.php> and
<http://www.php.net/manual/en/control-structures.foreach.php>.

--
Christoph M. Becker
Re: What is the purpose of "&" in this code? [message #186112 is a reply to message #186110] Sat, 14 June 2014 18:32 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
On 6/14/2014 11:08 AM, richard wrote:
>
> foreach($master as &$ma)
> $tmp[] = &$ma["date"];
> array_multisort($tmp, $master);
> foreach($master as &$ma)
> echo $ma["date"]."<br/>";
>

http://www.php.net/manual/en/language.references.pass.php
Re: What is the purpose of "&" in this code? [message #186115 is a reply to message #186110] Sat, 14 June 2014 20:04 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On Sat, 14 Jun 2014 11:08:48 -0400, richard wrote:

> [code]

Either (a) ask the person who wrote the code, or (b) read the manual
yourself.

--
Denis McMahon, denismfmcmahon(at)gmail(dot)com
Re: What is the purpose of "&" in this code? [message #186116 is a reply to message #186110] Sun, 15 June 2014 01:25 Go to previous message
Doug Miller is currently offline  Doug Miller
Messages: 171
Registered: August 2011
Karma: 0
Senior Member
richard <noreply(at)example(dot)com> wrote in news:tvhj7dle16f3$(dot)ro2c41zfpmyn(dot)dlg(at)40tude(dot)net:

>
> foreach($master as &$ma)
> $tmp[] = &$ma["date"];
> array_multisort($tmp, $master);
> foreach($master as &$ma)
> echo $ma["date"]."<br/>";
>

RTFM, RtS.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: function for preserving special characters?
Next Topic: How to loop through the dates?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 14:23:14 GMT 2024

Total time taken to generate the page: 0.02714 seconds