473,405 Members | 2,261 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Passing by refrence in FOREACH

moishy
104 100+
I have a problem when passing by refrence using FOREACH():

[PHP]
foreach ($array as &$value)
{if ($value <= 0)
{$value+=12;}}
[/PHP]

It should have worked, but I got a error:

Parse error: syntax error, unexpected '&', expecting T_VARIABLE or '$'

It even worked on a local testing server!
Nov 29 '06 #1
2 1559
[PHP]
foreach ($array as &$value)
{if ($value <= 0)
{$value+=12;}}
[/PHP]

foreach reference work on/for PHP5, as long as i know.
Nov 29 '06 #2
moishy
104 100+
So what is a loophole for earlier versions?
Nov 29 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Mike Guerrieri | last post by:
I have a few objects that I've created, Contact, Address, AddressCollection (inherits from CollectionBase), dtaContact, and dtaAddress. One of the properties of the Contact object...
5
by: JustSomeGuy | last post by:
Silly question maybe... I pass a refrence to an object to a method... The method adds the object to a (stl) list of these objects... However if a refrence to the object is passed and then added...
2
by: hits | last post by:
Should the following passing of private variable refrence work? ( Relates to the power of references to access private data variable). class B; class A { private: int var; void func_a() {
7
by: Jeff K | last post by:
Can you pass an int array by reference to a function and modify selective elements? Here is my code: #include <stdio.h> #define COLUMNSIZE 30 #define ASIZE 5...
2
by: Mat Andrews | last post by:
Hi, I'm comfused with this peice of code which I'm looking at. I can't figure out how it works (and it does appear too); ApplicationData appData = new ApplicationData(); ...
1
by: Darsin | last post by:
Hi all, I am a new programmer to C# and i am having a following problem. I want to make a single method which takes a variable length array and display it contents. i have defined the method as:...
5
by: Markus Ernst | last post by:
Hello A class that composes the output of shop-related data gets some info from the main shop class. Now I wonder whether it is faster to store the info in the output class or get it from the...
1
by: bhavinp | last post by:
hi, following my code snippet void ObAuthUser::SetInstanceFromToken(ObKeyValMap const & rKeyValMap) { char const * pAuthId = rKeyValMap.GetVal(kAuthIdKey);
11
by: Bob Yang | last post by:
Hi, I have this in C++ and I like to call it from c# to get the value but I fail. it will be good if you can give me some information. I tried it in VB.net it works but I use almost the same way as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.