Jump to content

$variable = Multiple values


sblake161189

Recommended Posts

Hi Guys,

 

I don't know how to do this but basically I want the value of $postcode3 to equal the value of $postcodep1 aswell as $postcodep2 like this...

 

else {$postcode3 = $postcodep1 $postcodep2;}

 

That doesn't work...

 

Say

$postcodep1 = LS14

$postcodep2 = 2AB

 

Then

$postcode3 = LS14 2AB

 

How do I write this in the above php code?!

 

Thanks,

S

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/226460-variable-multiple-values/
Share on other sites

Any of the following will work:

<?php
$postcodep1 = 'LS14';
$postcodep2 = '2AB';
$postcode3 = "$postcodep1 $postcodep2";
?>

 

<?php
$postcodep1 = 'LS14';
$postcodep2 = '2AB';
$postcode3 = $postcodep1 . ' ' . $postcodep2;
?>

 

<?php
$postcodes = array('LS14','2AB');
$postcode3 = implode(' ',$postcodes);
?>

 

Ken

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.