Globals or Super Global Variables To Be Reused from For Loops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, 

I have a snippet of code as shown in the following:

$message2="47406|Detroit";
$stringChunk2= explode("|", $message2);

 if ($message2!="") {
   $count_chunk2= count($stringChunk2);
   $count_chunk_2= $count_chunk2-1;
}

   for ($j=0; $j<$count_chunk2; $j++) {

          $string3= $stringChunk2[$j];       
      if ($j <$count_chunk_2) {
         $string2= " OR ";
         $string3=$string3.$string2;
   }
     else {
         //Don't do anything
   }
       echo $string3;
  }

The code itself works, but I would like to reuse $string3 variable somewhere else where I can build SQL statements from it. 
I tried using 

global $string3; 
echo $string3;

after the final curly brace, but I only get Detroit and not "47406 OR Detroit". Can anyone please suggest me what I should be using here?

Thanks for your help.

Alice

_________________________________________________________________
All-in-one security and maintenance for your PC.  Get a free 90-day trial!
http://www.windowsonecare.com/purchase/trial.aspx?sc_cid=wl_wlmail

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux