You are here: Re: Getting 'by reference' error using array_walk. How do I use it then? « PHP Programming Language « IT news, forums, messages
Re: Getting 'by reference' error using array_walk. How do I use it then?

Posted by Chung Leong on 11/18/05 21:27

lwoods wrote:
> I have the following function:
>
> function clean_form( &$from_check ) {
> if(is_array($from_check)){
> array_walk(&$from_check,'clean_form');
> return;
> } else {
> $value = str_replace(array("\r","\n","Content-Type:"),"",$from_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($from_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.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация