RE: [PHP] Problems with globals...

From: Date: Tue, 25 Jul 2000 16:19:29 +0000
Subject: RE: [PHP] Problems with globals...
Groups: php.general 
Request: Send a blank email to php-general+get-8077@lists.php.net to get a copy of this message
> do this: > make it global for use in the function, before you try to > manupliate it function stringsToLower( $stringsArray ) { global $stringVariable; for( $elNum = 0; $elNum < count( $stringsArray ); $elNum++ ) { $stringVariable = $stringsArray[$elNum]; $stringVariable = strtolower( $$stringVariable ); } } Huh? What is that going to do? It is going to set the variable $stringVariable as global; a variable which is defined nowhere else. Then, the rest of the code essentially goes nowhere. What I'm trying to do with the above loop is the same as this (in this particular example): function stringsToLower() { global $joe; global $bob; global $briggs; $joe = strtolower( $joe ); $bob = strtolower( $bob ); $briggs = strtolower( $briggs ); ) and putting the global statement outside the for loop will not do this. Thanks for the help, but I am not sure if I was explicit enough with what I need. Sorry. :/ Chris

« previous php.general (#8077) next »