Zend - The PHP Company




Miscellaneous

Add Code


Assign Variables from Array (an other)  

Type: application
Added by: chimondo1
Entered: 09/08/2002
Last modified: 08/12/2001
Rating: - (fewer than 3 votes)
Views: 3893
Takes an array and assigns it to the global space.


<?php
// void make_global(array array[, bool overwrite[, bool reference]])
 
function make_global(&$array$overwrite TRUE$reference FALSE){
  
reset($array);
  while(list(
$k$v) = each($array))
   if(
is_string($k) && (!isset($GLOBALS[$k]) || $overwrite)){
    if(
$reference)
     
$GLOBALS[$k] = &$v;
    else
     
$GLOBALS[$k] = $v>
   }
 }
?>


Usage Example




Rate This Script





Search



This Category All Categories