473,801 Members | 2,259 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting 'by reference' error using array_walk. How do I use it then?

I have the following function:

function clean_form( &$from_check ) {
if(is_array($fr om_check)){
array_walk(&$fr om_check,'clean _form');
return;
} else {
$value = str_replace(arr ay("\r","\n","C ontent-Type:"),"",$fro m_check);
}

When I call this function I get the following warning:

Warning: Call-time pass-by-reference has been deprecated - argument passed
by value; If you would like to pass it by reference, modify the declaration
of array_walk(). If you would like to enable call-time pass-by-reference,
you can set allow_call_time _pass_reference to true in your INI file.
However, future versions may not support this any longer.

In the PHP doc it shows referencing the array argument "by reference"; i.e.
'&' , but the runtime says this is a "no go". Then how am I supposed to use
array_walk?

TIA,

Larry Woods
Nov 22 '05 #1
2 2177
lwoods wrote:
function clean_form( &$from_check ) {
array_walk(&$fr om_check,'clean _form');


You need to define at least two parameters for the function you call with
array_walk: array and item. So try: function clean_form(&$fr om_check,
$value) { etc. }. That might take care of the error.

--
E. Dronkert
Nov 22 '05 #2
lwoods wrote:
I have the following function:

function clean_form( &$from_check ) {
if(is_array($fr om_check)){
array_walk(&$fr om_check,'clean _form');
return;
} else {
$value = str_replace(arr ay("\r","\n","C ontent-Type:"),"",$fro m_check);
}

When I call this function I get the following warning:

Warning: Call-time pass-by-reference has been deprecated - argument passed
by value; If you would like to pass it by reference, modify the declaration
of array_walk(). If you would like to enable call-time pass-by-reference,
you can set allow_call_time _pass_reference to true in your INI file.
However, future versions may not support this any longer.

In the PHP doc it shows referencing the array argument "by reference"; i.e.
'&' , but the runtime says this is a "no go". Then how am I supposed to use
array_walk?

TIA,


array_walk() is declared to take a reference as the first argument, so
you don't need to use & when you call the function. Just do
array_walk($fro m_check,'clean_ form').

The error message is bogus though. The array will still be passed by
reference in this instance. Report it as a bug.

Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1967
by: Phil Powell | last post by:
<?php class Grad { var $dbFormExemptionArray = array(); function Grad ($id = '') { /*---------------------------------------------------------------------------------------------------------------------- Do note that if you are generating arrays that will not have
2
2961
by: Reply-Via-Newsgroup | last post by:
Folks, I have a multi-dimensional array that I read from my mysql database. I'd like to run strip slashes against each element and I'm pretty sure that array_walk() (or array_map) is likely to solve my problem - But I've not got the foggiest on how to use it - I've taken a look in the php.chm manual supplied from php.net and I don't seem to have had any success so far - Can anyone suggest how I could stripslashes to every element...
6
3052
by: steve | last post by:
Hi, I have never used array_walk, and quite frankly, cannot see why I should use it instead of foreach. Can someone shed some light on the cases where array_walk is the one to use, and what php developers where thinking when they coded this operator. Thanks. --
2
2191
by: David | last post by:
Hi, Could PHP be used to take a txt file (or set of txt files) and add a string of characters every X number of words or characters? Say a txt file with 50,000 characters/5,000 words how would you go about adding a string of characters every 5,000 characters or 500 words. To improve on this I'd want to if using characters as the guide to use
0
9698
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9556
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10262
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10052
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9101
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7589
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6829
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5479
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4156
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.