almightyegg Posted March 30, 2008 Share Posted March 30, 2008 Is there a way to take a variable and split the actual variable apart. Eg. $p1d2 I would like to remove the $ and split it into an array [0] = 1 and [1] = 2 Any ideas? If possible at all Quote Link to comment Share on other sites More sharing options...
ucffool Posted March 31, 2008 Share Posted March 31, 2008 Check out the functions: chunk_split() explode() Quote Link to comment Share on other sites More sharing options...
almightyegg Posted April 2, 2008 Author Share Posted April 2, 2008 No I mean take the variable $p1d2 and turn it into just p12d - stop it being a variable..but still have the name of it Quote Link to comment Share on other sites More sharing options...
trq Posted April 2, 2008 Share Posted April 2, 2008 As I said last time you where playing with this idea, you need to rethink your logic. $variables simply hold values, they can be named whatever, but dynamically naming variables and trying to manipulate them in such a way is not usually the right way of going about things. Maybe if you explained the bigger picture we could offer an alternative. Quote Link to comment Share on other sites More sharing options...
unsider Posted April 2, 2008 Share Posted April 2, 2008 Ya, I'm confused as to why you would need to do this. Seems like there might be a more effective solution to your problem. Quote Link to comment Share on other sites More sharing options...
almightyegg Posted April 2, 2008 Author Share Posted April 2, 2008 It's needed in this function type thing: $im = imagecreate(150, 100); $i = 1; $h = 1; while($i <> 16 && $h <> 11){ $p = ${"p" . $i . "d" . $h}; $f = ($i-1)*10; $s = $i*10; $g = ($h-1)*10; $r = $h*10; $black = imagecolorallocate($im, 102, 51, 0); $red = imagecolorallocate($im, 255, 0, 0); $brown = imagecolorallocate($im, 255, 147, 28); $turq = imagecolorallocate($im, 153, 255, 255); $flares = mysql_fetch_array(mysql_query("SELECT * FROM itemsowned WHERE userid = '{$mem['id']}' and code = 'flar'")); $vmap = mysql_fetch_array(mysql_query("SELECT * FROM itemsowned WHERE userid = '{$mem['id']}' and code = 'vmap'")); $flares = $flares[amount]; $vmap = $vmap[amount]; if($p == x){ imagefilledrectangle($im, $f, $g, $s, $r, $black); }elseif($p == v && $vmap == 1){ imagefilledrectangle($im, $f, $g, $s, $r, $turq); }elseif($p == m && $vmap == 1){ imagefilledrectangle($im, $f, $g, $s, $r, $turq); }else{ imagefilledrectangle($im, $f, $g, $s, $r, $brown); } if($i == 15 && $h == 10){ $h = $h+1; $i = $i+1; }elseif($i == 15){ $i = 1; $h = $h+1; }else{ $i = $i+1; } } This works (mostly) but I want to add another if. Basically I want to say if(the-point-the-user-is-on == p$id$h){ etc.. That make more sense? Quote Link to comment Share on other sites More sharing options...
almightyegg Posted April 2, 2008 Author Share Posted April 2, 2008 Oh my, the answer was right in my face oops. Sorry guys it's sorted though that function still isn't working 100% and I've been trying to fix that for days. it shows The data is there for it to make the rest but isn't... Quote Link to comment 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.