hatrickpatrick Posted August 21, 2007 Share Posted August 21, 2007 Supposing I have one variable, $file=filename, and a second variable, which is $number='99'; How can I make a third variable, $fileno which will equal filename99? I'm guessing it's not as simple as $fileno=$file$number... Quote Link to comment https://forums.phpfreaks.com/topic/66040-solved-combining-two-variables-together-to-make-a-new-one/ Share on other sites More sharing options...
roopurt18 Posted August 21, 2007 Share Posted August 21, 2007 This is called concatenation: $var = $var1 . $var2; Quote Link to comment https://forums.phpfreaks.com/topic/66040-solved-combining-two-variables-together-to-make-a-new-one/#findComment-330262 Share on other sites More sharing options...
BlueSkyIS Posted August 21, 2007 Share Posted August 21, 2007 or.. $fileno="$file$number"; (just add double-quotes) Quote Link to comment https://forums.phpfreaks.com/topic/66040-solved-combining-two-variables-together-to-make-a-new-one/#findComment-330282 Share on other sites More sharing options...
hatrickpatrick Posted August 21, 2007 Author Share Posted August 21, 2007 Thank you VERY much. Just one more thing - using the first method, if I wanted to separate the two variables with an underscord, so it'd be filename_99, how would I add that in? Quote Link to comment https://forums.phpfreaks.com/topic/66040-solved-combining-two-variables-together-to-make-a-new-one/#findComment-330305 Share on other sites More sharing options...
effigy Posted August 21, 2007 Share Posted August 21, 2007 Based on the example below, how do you think it would be done? The concept has already been demonstrated. Are you familiar with strings? This is called concatenation: $var = $var1 . $var2; Quote Link to comment https://forums.phpfreaks.com/topic/66040-solved-combining-two-variables-together-to-make-a-new-one/#findComment-330311 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.