Strings are usually in variables? Where does this string come from? Can you explain a little more? Examples?
Like I have $var = "name" and want to make a new variable $namefull where the "name" in $namefull came from $var.
You can do it like that: $firstname = 'Name'; $lastname = 'Last'; $fullname = "{$fistname} {$lastname}"; PHP: Or $lastname = 'Last'; $fullname = "Name {$lastname}"; PHP:
I was thinking something more along the lines of //does this work? $var a = "name"; $($var)."full" = "Hello, world!"; echo $namefull; //should display "Hello, world!"...or would it? :p PHP: So it's creating a new variable from the contents of another variable. How is this done?
Ahh, I understand your question now. What you're talking about is called Variable variables. $var = "name"; ${$var . "full"} = "Hello, world!"; echo $namefull; PHP:
So it's a variable variable. I always thought those were just confusing, and here I am looking into them without even knowing. Btw, when do you use the "{}" when typing code?
Yes, they can be confusing at times. And I don't suggest using them unless you have a good reason to. Usually you can use arrays instead.
Haha. I understand. But when is the right way to use them other than concatenating to form a variable variable?
lol why not do: $firstname = 'Name'; $lastname = 'Last'; $fullname = $firstname . ' ' . $lastname; echo $fullname; PHP: ?
There is no "right". It's right when you feel like using them and it works. In some cases it's just easier to use arrays. There are no rules though. So you're free to do what you like. But In a few cases it's the opposite, and it's easier to use variable variables, so it's hard to tell what's most appropriate for you without seeing your code.
There are loads of ways I agree. Mine had more chance of working though as you put: {$fistname} $fullname = "{$fistname} {$lastname}"; PHP: lol- joke I've seen a few of your PHP help comments, you are very talented. A great knowlege of PHP
I saw that too, hehe. But that doesn't matter as much. I agree with using what you feel is right. Nico_swd you're very talented indeed, most of my posts have been answered by you and it's just great.