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
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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.