Reply to Re: How to pass array names to function parameters ?

Your name:

Reply:


Posted by Sidonath on 04/16/06 15:15

I knew that I forgot something :/

$HTTP_*_VARS arrays are not superglobal. Hence you need to specify in
function that you're using global arrays or access them with $GLOBALS
array

Here's a bit modified example that should work:

------------------------

// custom global array
$myArray = array("some", "elements");

// array with names of global arrays you want to access
$globalArrayNames = array("HTTP_GET_VARS", "HTTP_POST_VARS",
"myArray");

// parameter is global array name
function showThisArray($globalArrayName) {
echo($globalArrayName . "\n"); // debug line
foreach($GLOBALS[$globalArrayName] as $k => $v ) {
echo($k . " = " . $v . "\n");
}
}

showThisArray($globalArrayNames[0]);
showThisArray($globalArrayNames[1]);
showThisArray($globalArrayNames[2]);

------------------------

Hope this helps

[Back to original 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

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