HuggieBear Posted August 31, 2006 Share Posted August 31, 2006 I think this is an interpolation question but I'm not sure.I have the following code, now I know the code's not ideal, but I'm putting it like this so I can learn.[code=php:0]<?php$fruit = $_GET['fruit'] // The value of 'fruit' is going to be a text string passed from a form of either "$apple" or "$grape"$apple[]="red";$apple[]="green";$grape[] = "purple";$grape[] = "green";foreach ($var as $colour){ // how can I make $var whatever the value of $fruit is I guess I need to interpolate the variable echo $colour;}?>[/code]I hope this made sense.RegardsRich Quote Link to comment https://forums.phpfreaks.com/topic/19293-possible-interpolation-solved/ Share on other sites More sharing options...
Barand Posted August 31, 2006 Share Posted August 31, 2006 foreach ($$fruit as $colour){ echo $colour;} Quote Link to comment https://forums.phpfreaks.com/topic/19293-possible-interpolation-solved/#findComment-83681 Share on other sites More sharing options...
HuggieBear Posted September 1, 2006 Author Share Posted September 1, 2006 Thanks Barand,Just perfect ;DRich Quote Link to comment https://forums.phpfreaks.com/topic/19293-possible-interpolation-solved/#findComment-83898 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.