gilk9 Posted January 5, 2010 Share Posted January 5, 2010 I need to construct a new file name from the words "Lesson" and ".zip" and a variable $lessonnumber. The three elements are in the order Lesson $lessonnumber .zip The final format of the new variable $newfile would be Lesson123.zip I have been experimenting with variations of $lesson = 'Lesson '; $zip = '.zip'; $newfile = $lesson.$nextlessonnum.$zip; Trying to concatenate numbers and strings has got me beat! All help appreciated,thanks Quote Link to comment https://forums.phpfreaks.com/topic/187220-concatenation-help-please/ Share on other sites More sharing options...
oni-kun Posted January 5, 2010 Share Posted January 5, 2010 What are you trying to do? $nextlessonnum = 123; $lesson = 'Lesson'; $zip = '.zip'; $newfile = $lesson.$nextlessonnum.$zip; echo $newfile; //Output: Lesson123.zip That works fine. Concatinating strings and numbers are the same. http://php.net/manual/en/language.types.type-juggling.php Quote Link to comment https://forums.phpfreaks.com/topic/187220-concatenation-help-please/#findComment-988669 Share on other sites More sharing options...
gilk9 Posted January 5, 2010 Author Share Posted January 5, 2010 Thanks for that, I was wanting confirmation that my general coding direction was appropriate. It was. When I commented out lines one by one I found my error. Just had a stray character causing the problem. Thanks again, D Quote Link to comment https://forums.phpfreaks.com/topic/187220-concatenation-help-please/#findComment-988719 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.