| How to add text inside variable?
|
toplisek

msg:4252772 | 11:41 am on Jan 13, 2011 (gmt 0) | I have variable and inside this variable I like to set variable. How to do this? $myvariable1 = "$myvariable2 [0],facebook marketing"; How to do validated code for this that string will be seen with $myvariable2 [0]
|
alias

msg:4252779 | 12:03 pm on Jan 13, 2011 (gmt 0) | PHP eval is the function you need: [php.net...]
|
Matthew1980

msg:4252789 | 12:19 pm on Jan 13, 2011 (gmt 0) | Hi all, Unless I have misread the intention here, your nearly there with the example you have given:- $myvariable1 = $myvariable2[0]."facebook marketing"; echo $myvariable1; This would then print (for arguments sake) something like this:- Contents of variable facebook marketing if your joining variables together, you need to use the '.' full stop, this then concatenates the values together and stores them into the new name as you have assigned them to using the '=' assignment operator. Cheers, MRb
|
rocknbil

msg:4253384 | 5:28 pm on Jan 14, 2011 (gmt 0) | A second example, keeping in mind that scalar variables will interpolate with double quotes. $fruits = Array ( 'one' => 'cherries', 'two' => 'apples', 'three' => 'pears' ); $animals = Array('lions','tigers','bears'); The following are equivalent, one may be more legible and easier to debug for you than the other depending on your style. $output = "<p>Joebob walked his " . $animals[1] . " to the store to buy " . $fruits['one'] . ".</p>"; $myanimal = $animals[1]; $myfruit = $fruits['two']; $output = "<p>Joebob walked his $myanimal to the store to buy $myfruit.</p>";
|
|
|