almightyegg Posted March 30, 2008 Share Posted March 30, 2008 I have lots of variables. The way I get the right one is like: $p$xd$y. Eg. if $x = 1 and $y = 4 it's $p1d4. I have got it to the point where I can get it to p1d4. But that's in another variable "$n = p1d4;" I want to put into an if{ }else{ } if($p1d4 == .. ){ but I can't work out a way to get it in the first place... If anypone can shed some light onto this it'd be great Link to comment https://forums.phpfreaks.com/topic/98655-another-variable-problem/ Share on other sites More sharing options...
trq Posted March 30, 2008 Share Posted March 30, 2008 You might need to post some code to shed some light on your issue. There isn't alot of sense in your description. Link to comment https://forums.phpfreaks.com/topic/98655-another-variable-problem/#findComment-504893 Share on other sites More sharing options...
ohdang888 Posted March 30, 2008 Share Posted March 30, 2008 $p1d4 is a variables, hold infom p1d4 is stored in a variable... 2 entirely separate things. Link to comment https://forums.phpfreaks.com/topic/98655-another-variable-problem/#findComment-504896 Share on other sites More sharing options...
almightyegg Posted March 30, 2008 Author Share Posted March 30, 2008 Sorry I did waffle a bit didn't I? Hmm $p1d1 = o; $p2d1 = o; $p3d1 = x; $p4d1 = x; $p5d1 = x; $p6d1 = x; $p7d1 = x; $p8d1 = x; $p9d1 = o; $p10d1 = x; $n = $y-1; $n = "$p" . $x . "d" . $n .""; $s = $y+1; $s = "$p" . $x . "d" . $s .""; $e = $x+1; $e = "$p" . $e . "d" . $y .""; $w = $x-1; $w = "$p" . $w . "d" . $y .""; Basically, I want $n to equal $p1d0 - if $x = 1 and $y = 1 More sense? Link to comment https://forums.phpfreaks.com/topic/98655-another-variable-problem/#findComment-504902 Share on other sites More sharing options...
trq Posted March 30, 2008 Share Posted March 30, 2008 I'm thinking you need to rethink your logic, but variable variables may help. Example. <?php $n = ${$p . $x . "d" . $n}; ?> Link to comment https://forums.phpfreaks.com/topic/98655-another-variable-problem/#findComment-504910 Share on other sites More sharing options...
almightyegg Posted March 30, 2008 Author Share Posted March 30, 2008 That worked great thanks Link to comment https://forums.phpfreaks.com/topic/98655-another-variable-problem/#findComment-504914 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.