Hey everyone.

For backup purposes, I have some emails that are sent to me when someone completes a survey on my site. This morning mySQL died after we sent out a targeted customer survey and none of our data was recorded to the database. But, I did receive the emails.

So now I have 50+ emails with the contents of

print_r( $_POST )

from the answers to the survey. Is there a way to interpret the output from print_r and actually evaluate the $_POST array? I know this is crazy, but I'm thinking that there might be a solution out there...

Thanks.

    You'd have to do a bit of string parsing yourself; print_r() was meant for debugging, not archival or transactional purposes. If you'd used var_dump() you'd have had an easier time of it, but you'd still have been better off storing something more machine-readable (or more human-readable, being in an email).

    That said, the main thing that would need to be done with the output of print_r() would be to replace [foo] with 'foo', and then quote the array values as well (except for any that are themselves arrays, of course). Then put an $array = in front of it and a ; on the end. I think that would make for legitimate PHP code that can be eval()ed.

      Weed,

      That's the route I'm going by... When I'm done I'll post some code here in case anyone else needs it.

      Thanks for your feedback. If anyone else has any code to do this, please let me know.

        Write a Reply...