You are here: Re: Passing array by reference. « PHP Language « IT news, forums, messages
Re: Passing array by reference.

Posted by Martin Mandl - m2m tech support on 01/15/07 08:07

Dear David,

have a look at the comments on
http://at.php.net/manual/en/function.array-walk.php

It seems

bool array_walk ( array &array, callback funcname [, mixed userdata]
)

passing the userdata as reference does not work (as well as trying to
modify the key) ...

Cheers

David Smithz wrote:
> Is it possible to pass arrays by reference?
>
> Already have a work around for the below by using a foreach instead, but I
> am still interested to know why the below did not work as the final array
> was always blank despite my debugging output suggesting everything works
> inside the function.
>
> The code below uses the array walk function:
>
>
>
> function check_if_FV_TES ($value, $key, &$ary_of_FVs) {
> echo "<BR>Here we are: $key $value," . substr($key, 0, 6);
>
> if (substr($key, 0, 6)=="FV_TES") {
> echo "<BR>We got a match:". substr($key,11);
> #Place this key and string into another variable (note we get the part
> after 9 characters as the first 9 identify fiel type, actual name starts
> then
> $ary_of_FVs[substr($key,11)] = $value;
> echo "<BR>:here is the array so far:";
> print_r($ary_of_FVs);
> };
> }
>
> #Create a blank array to stor the form variables
> $ary_Fulllist_of_FVs = array();
>
> #Call the array walk
> array_walk($_REQUEST, 'check_if_FV_INP', $ary_Fulllist_of_FVs );
>
>
> $ary_Fulllist_of_FVs - always had a blank array at the end.
>
> Any ideas?

 

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

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