You are here: Re: How to pass array names to function parameters ? « PHP Programming Language « IT news, forums, messages
Re: How to pass array names to function parameters ?

Posted by tony on 04/18/06 11:24

In article <1145310837.226085.226960@g10g2000cwb.googlegroups.com>,
kenrbnsn@gmail.com says...

> Here's another way of doing this.
>
> <?php
> // custom global array
> $myArray = array("some", "elements");
>
> // array with names of global arrays you want to access
> $globalArrayNames =
> array(array('$_SERVER',$_SERVER),array('$_POST',$_POST),
> array("myArray",$myArray));
>
> // parameter is global array name
> function showThisArray($globalArrayName) {
> echo("<br><br>" . "[ " . $globalArrayName[0] . " ]<br>");
> echo '<pre>' . print_r($globalArrayName[1],true) . '</pre>';
> }
>
> showThisArray($globalArrayNames[0]);
> showThisArray($globalArrayNames[1]);
> showThisArray($globalArrayNames[2]);
> ?>
>
>
> Ken
>
>

And there was me thinking it couldnt be done ... ;-)
Now we have two ways.

Correct me if I'm wrong though Ken but doesnt this method pass the actual
array rather than just the name?

I'm not sure because I'm not able to work out what this is doing exactly
(I'm new to PHP as you may have gathered)

tony

 

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

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