RE: [PHP] Problems with globals...
| From: | Chris Murley | Date: | Tue, 25 Jul 2000 16:11:16 +0000 |
| Subject: | RE: [PHP] Problems with globals... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-8079@lists.php.net to get a copy of this message | ||
OHH, then remove the global all together...
once you assign $stringVariable, itr will be available outside the
function, or hell, return() if if you want....
> function stringsToLower( $stringsArray ) {
> for( $elNum = 0; $elNum < count( $stringsArray ); $elNum++ ) {
>
> $stringVariable = $stringsArray[$elNum];
>
> $stringVariable = strtolower( $$stringVariable );
>
> }
> }
>
On Tue, 25 Jul 2000, Boget, Chris wrote:
> > do this:
> > make it global for use in the function, before you try to
> > manupliate it
>
>
> 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
>