Brian W Posted September 19, 2008 Share Posted September 19, 2008 if i have $Value1 = "hello"; $Value2 = "world"; and I want to combine the two like $helloworld how could I do that? Quote Link to comment https://forums.phpfreaks.com/topic/124902-newb-question-i-think/ Share on other sites More sharing options...
Maq Posted September 19, 2008 Share Posted September 19, 2008 $Value1 .= $Value2; Quote Link to comment https://forums.phpfreaks.com/topic/124902-newb-question-i-think/#findComment-645382 Share on other sites More sharing options...
Brian W Posted September 19, 2008 Author Share Posted September 19, 2008 let me revise that ___ if i have $Value1 = "hello"; $Value2 = "world"; $Value3 = "HI" and I want to combine the two three $helloworld = HI how could I do that? Quote Link to comment https://forums.phpfreaks.com/topic/124902-newb-question-i-think/#findComment-645384 Share on other sites More sharing options...
Maq Posted September 19, 2008 Share Posted September 19, 2008 if i have $Value1 = "hello"; $Value2 = "world"; $Value3 = "HI" and I want to combine the two three $helloworld = HI how could I do that? I'm sorry I don't understand this question. The '.' is a concatenation string. So when you write $Value1 .= $Value2; It's the same thing as: $Value1 = $Value1 ."". $Value2; If this doesn't help please just tell me the three vars and what final result you want. Quote Link to comment https://forums.phpfreaks.com/topic/124902-newb-question-i-think/#findComment-645388 Share on other sites More sharing options...
Brian W Posted September 19, 2008 Author Share Posted September 19, 2008 The variables are from a data base. I'm trying to populate certain cell (out of a 50x50 cell table). If $row_pos['left'] = "4" and $row_pos['top'] = "3", and $row_pos['word'] = "HI" I want it to come out as $cell4x3 = "HI" in my table in the cell 4 over and 3 down, there is echo $cell4x3 Quote Link to comment https://forums.phpfreaks.com/topic/124902-newb-question-i-think/#findComment-645392 Share on other sites More sharing options...
DarkerAngel Posted September 19, 2008 Share Posted September 19, 2008 this is the best I can do for ya that does what you want. <?php eval("\$cell" . $row_pos['left'] . "x" . $row_pos['top'] . " = \"" . $row_pos['word'] . "\";"); ?> God knows why you need something like that but there it is. Quote Link to comment https://forums.phpfreaks.com/topic/124902-newb-question-i-think/#findComment-645409 Share on other sites More sharing options...
JasonLewis Posted September 19, 2008 Share Posted September 19, 2008 What are you trying to achieve exactly? I'm sure it'll be just as if not easier to keep it in arrays or even transform it into a slightly easier to manage array to achieve the desirable outcome. Quote Link to comment https://forums.phpfreaks.com/topic/124902-newb-question-i-think/#findComment-645411 Share on other sites More sharing options...
GingerRobot Posted September 19, 2008 Share Posted September 19, 2008 Well, it is possible like so: $Value1 = "hello"; $Value2 = "world"; $Value3 = "HI"; ${$Value1.$Value2} = $Value3; echo $helloworld; However, i agree with ProjectFear that there might be a better solution in the long run if you explain your problem some more. Quote Link to comment https://forums.phpfreaks.com/topic/124902-newb-question-i-think/#findComment-645443 Share on other sites More sharing options...
F1Fan Posted September 19, 2008 Share Posted September 19, 2008 I agree. A multidimensional array is your best bet. <?php $Value1 = "hello"; $Value2 = "world"; $Value3 = "HI"; $array[$Value1][$Value2] = $Value3; print_r($array); ?> Quote Link to comment https://forums.phpfreaks.com/topic/124902-newb-question-i-think/#findComment-645594 Share on other sites More sharing options...
Brian W Posted September 19, 2008 Author Share Posted September 19, 2008 Sorry, i'm making a game board that has 40 x 40 cells. Each cell was going to have a string (such as 2 across and 1 down would have $x3y1) Players would add entries into the database with a picture's source from a list I have (20x20px pics) and x and y positioning choices. I then have a repeat field that takes the info from the database and converts it into the image script in the right place. $x3y1 = "<img src=\"$row_pos['src']\" > \\ or something like that. I changed over to a repeating background of chess board like squares to create my board (less script, better refresh time) and set it up to have absolute positioning instead. (tid bit from it: absolute; left; ".10+(20*$row_pos['X'])."...(*20 because each square is 20pixels and + 10 because the screen margins 10 from the top and left.)) Quote Link to comment https://forums.phpfreaks.com/topic/124902-newb-question-i-think/#findComment-645629 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.