dsp77 Posted May 11, 2011 Share Posted May 11, 2011 Hello, i have the code below and i need to have all results in a variable as a string, inside the loop they are displayed how i want but outside will echo the last result. Thank You. foreach($_POST as $key=>$value){ if (is_numeric($value)) { $valoare = "$value,"; } } echo $valoare; Quote Link to comment https://forums.phpfreaks.com/topic/236090-convert-loop-foreach-results-to-a-variable-string/ Share on other sites More sharing options...
phppaper Posted May 11, 2011 Share Posted May 11, 2011 foreach($_POST as $key=>$value){ $valoare .= $value.","; } echo $valoare; If uou mean they all join together as string. Quote Link to comment https://forums.phpfreaks.com/topic/236090-convert-loop-foreach-results-to-a-variable-string/#findComment-1213709 Share on other sites More sharing options...
dsp77 Posted May 11, 2011 Author Share Posted May 11, 2011 oh yes, that is so obvious hehe didn't cross my mind, thank you. Quote Link to comment https://forums.phpfreaks.com/topic/236090-convert-loop-foreach-results-to-a-variable-string/#findComment-1213710 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.