Hello @kartik,
Try var_export
You may want to check out var_export — while it doesn't provide the same output as var_dump it does provide a second $return parameter which will cause it to return its output rather than print it:
$debug = var_export($my_var, true);
Hope it helps!!
Thank You!!