sblake161189 Posted February 2, 2011 Share Posted February 2, 2011 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 Quote Link to comment Share on other sites More sharing options...
litebearer Posted February 2, 2011 Share Posted February 2, 2011 1. use an array or; 2. concatenate using a 'separator' or; ... Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted February 2, 2011 Share Posted February 2, 2011 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 Quote Link to comment Share on other sites More sharing options...
sblake161189 Posted February 2, 2011 Author Share Posted February 2, 2011 Thanks guys thats a great help - works beautifully Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.