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 :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
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 11:08 Go to next message
Mr Oldies is currently offline  Mr Oldies
Messages: 241
Registered: October 2013
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
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 11: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
add to buddy list
ignore all messages by this user
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 14:32 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
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 16:04 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
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] Sat, 14 June 2014 21:25 Go to previous message
Doug Miller is currently offline  Doug Miller
Messages: 171
Registered: August 2011
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
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.
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
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: Mon Oct 23 00:22:50 EDT 2017

Total time taken to generate the page: 0.00587 seconds