oobradersoo Posted January 25, 2014 Share Posted January 25, 2014 if you have 4 variables is there anyway to link them into one variable? { $number1 $number2 $number3 $number4 } $wholenumber Quote Link to comment https://forums.phpfreaks.com/topic/285659-variables/ Share on other sites More sharing options...
Skewled Posted January 25, 2014 Share Posted January 25, 2014 Using arithmetic? Quote Link to comment https://forums.phpfreaks.com/topic/285659-variables/#findComment-1466485 Share on other sites More sharing options...
denno020 Posted January 25, 2014 Share Posted January 25, 2014 (edited) Depends on what you mean by 'link them into one variable'. //You can add/subtract/divide/multiply them all, as suggested by kadeous $wholenumber = $number1 + number2 + $number3 + $number4; $wholenumber = $number1 - number2 - $number3 - $number4; $wholenumber = $number1 / number2 / $number3 / $number4; $wholenumber = $number1 * number2 * $number3 * $number4; //You can concatenate them $wholenumber = $number1 . $number2 . $number3 . $number4 //You can put them into an array $wholenumber = array( $number1, $number2, $number3, $number4 ); Those are three very basic things that you could do to 'link' them, which is all we can really suggest without more information as to what you actually want Denno Edited January 25, 2014 by denno020 Quote Link to comment https://forums.phpfreaks.com/topic/285659-variables/#findComment-1466486 Share on other sites More sharing options...
ginerjm Posted January 25, 2014 Share Posted January 25, 2014 You can also write $number1 = $number2 = $number3 = $number4; But if you are doing this - why do you even HAVE 4 variables? Sloppy code work? Quote Link to comment https://forums.phpfreaks.com/topic/285659-variables/#findComment-1466500 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.