If I use print_r or var_dump it displays the result on the screen, but I want this data to be stored in a variable so that I can write it to a file
print_
var_dump
ob_start(); var_dump($someVar); $result = ob_get_clean();
it works.