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 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? 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 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 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? Link to comment https://forums.phpfreaks.com/topic/285659-variables/#findComment-1466500 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.