Since I started using PHP, one of the minor items that I have always had was concatenating variables together that make up a string of text.

In this case it is an address field using the phoogle.php class for Google maps API.

Example:

$street = $_GET['street'];
$city   = $_GET['city'];
$state  = $_GET['state'];
$zip    = $_GET['zip'];

format to pass to the class is this

$map->addAddress('208 Dingler Ave, Mooresville, NC 28115'); 

so I tried this

$map->addAddress('{$street}, {$city}, {$state} {$zip}');

and tried to echo that out to the screen to see what I am getting, but I cannot get pas the class errors.

Can someone please show me the proper way to concat these fields or show me a really good tutorial on the web, because I cannot find one

Thanks in Advance

Mike

    I don't know for sure. Have you tried either of these:

    $map->addAddress($street.", ".$city.", ".$state." ".$zip); 
    

    or

    $temp = $street.", ".$city.", ".$state." ".$zip;
    $map->addAddress($temp); 

      I mean would this be right? :

      $address_string = (''$street'.","'.$city.'"," '.$state.'" " '.$zip.' ');
      

        $address_string = ('$street' , '$city' , '$state' , '$zip');

          etully wrote:

          I don't know for sure. Have you tried either of these:

          $map->addAddress($street.", ".$city.", ".$state." ".$zip); 
          

          or

          $temp = $street.", ".$city.", ".$state." ".$zip;
          $map->addAddress($temp); 

          Thanks etully these both work and will give me an idea of what I need to do in the future so that concatenation does not kick my arse all the time

          ~Mike

            Write a Reply...