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 Link to comment https://forums.phpfreaks.com/topic/226460-variable-multiple-values/ 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; ... Link to comment https://forums.phpfreaks.com/topic/226460-variable-multiple-values/#findComment-1168872 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 Link to comment https://forums.phpfreaks.com/topic/226460-variable-multiple-values/#findComment-1168876 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 Link to comment https://forums.phpfreaks.com/topic/226460-variable-multiple-values/#findComment-1168900 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.