ziggelflex Posted March 31, 2022 Share Posted March 31, 2022 (edited) I have this. $root = './dir1'; $structure = .$root."./dir2/dir3/dir4/dir5/dir6"; and I want the $structure variable to contain ./dir1/dir2/dir3/dir4/dir5/dir6 Any help. I know this is very basic. So thanks in advance Edited March 31, 2022 by ziggelflex Quote Link to comment https://forums.phpfreaks.com/topic/314650-concatenate-a-variable-and-a-string-into-another-variable/ Share on other sites More sharing options...
ginerjm Posted March 31, 2022 Share Posted March 31, 2022 You were close. $structure = $root . "/dir2/dir3/dir4/dir5/dir6"; This line will take the contents of $root and append the string following the connecting dot. Not sure why your starting value of $structure has a leading dot in it but you probably know. Quote Link to comment https://forums.phpfreaks.com/topic/314650-concatenate-a-variable-and-a-string-into-another-variable/#findComment-1594781 Share on other sites More sharing options...
Solution Zane Posted March 31, 2022 Solution Share Posted March 31, 2022 Why do you have a period in front of $root? Besides, that, this should work (without the period) Quote Link to comment https://forums.phpfreaks.com/topic/314650-concatenate-a-variable-and-a-string-into-another-variable/#findComment-1594782 Share on other sites More sharing options...
Barand Posted March 31, 2022 Share Posted March 31, 2022 Or you can do it without any concatenation operators. $root = './dir1'; $structure = "$root/dir2/dir3/dir4/dir5/dir6"; Quote Link to comment https://forums.phpfreaks.com/topic/314650-concatenate-a-variable-and-a-string-into-another-variable/#findComment-1594783 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.