ultrus Posted June 24, 2008 Share Posted June 24, 2008 Hello, I'm troubleshooting data coming in from $_POST, and am thinking it would be nice to list the variable keys and values. I can do this using print_r(), but in this case I need to assign the keys and values to a string then email it to me instead this time. How would I do this? If I figure this out first, I'll post the answer. Thank you much! Link to comment https://forums.phpfreaks.com/topic/111710-solved-assign-all-post-data-to-a-string/ Share on other sites More sharing options...
rhodesa Posted June 24, 2008 Share Posted June 24, 2008 Are you just looking for something like: $string = print_r($_POST,true); or $string = ""; foreach($_POST as $key=>$value) $string .= "{$key}: $value\n"; Link to comment https://forums.phpfreaks.com/topic/111710-solved-assign-all-post-data-to-a-string/#findComment-573413 Share on other sites More sharing options...
craygo Posted June 24, 2008 Share Posted June 24, 2008 foreach($_POST as $key => $val){ $array[] = "Key:$key = Value: $val"; } $string = implode(", ", $array); Ray Link to comment https://forums.phpfreaks.com/topic/111710-solved-assign-all-post-data-to-a-string/#findComment-573415 Share on other sites More sharing options...
ultrus Posted June 24, 2008 Author Share Posted June 24, 2008 Oh wow. I'm off today. That was easy... and just what I needed! Thanks for the awesome and super fast feedback. Link to comment https://forums.phpfreaks.com/topic/111710-solved-assign-all-post-data-to-a-string/#findComment-573420 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.