rockinaway Posted September 30, 2008 Share Posted September 30, 2008 I have a foreach loop: foreach ($array as $key => $value) { } Now what I want to do: - Say the $value is 'test'. In the foreach, I want to add an ending to this $value, and create a variable with that name. So eventually I will have a variable called $test_ending, from that initial $value. I have tried dong things like $value.$ending... doesn't work :S Link to comment https://forums.phpfreaks.com/topic/126474-foreach-and-add-vars/ Share on other sites More sharing options...
trq Posted September 30, 2008 Share Posted September 30, 2008 foreach ($array as $key => $value) { if ($value == 'test') { ${$value . '_ending'}; } } Link to comment https://forums.phpfreaks.com/topic/126474-foreach-and-add-vars/#findComment-653974 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.