Looking for workaround: print_r and var_export cannot run with ob_start's callback function

the functions print_r() and var_export() cannot be run within my ob_start's callback function because those functions use ob_start() internally.  Does anyone know of a workaround so I can simply spit out an array within my callback?
<?php
function mycallback ($buffer){
	$array=(1,2,3,4,5);
	
	//neither of these work
	$result=print_r($array,true);
	$result=var_export($array,true);
 
	$buffer.="<div class=\"debug\">".$result."</div>";
 
	return $buffer;
}
 
  ob_start("mycallback");//buffer on
    include("helloworld.html");
  ob_end_flush();
 
?>

Open in new window

LVL 1
dban00bAsked:
Who is Participating?
 
dban00bAuthor Commented:
done and done!
0
 
ddrudikCommented:
Thanks for the question and the points.
0
 
dban00bAuthor Commented:
No problem, thank you!  I messed around with this for an hour or so before giving up and posting here, and you got my the solution in 10 minutes!!
0
All Courses

From novice to tech pro — start learning today.