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; 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. 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. 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
Archived
This topic is now archived and is closed to further replies.