hankknight
asked on
var_dump to variable
How can I var_dump to a variable?
This does NOT work
This does NOT work
<?php
$zzz=array('111','222',333);
$qqq = var_dump($zzz);
?>
Try:
<?php
$zzz=array('111','222',333);
$qqq = print_r($zzz,true);
echo $qqq;
?>
With print_r() you need to set the return parameter to true.
If you would like to capture the output of print_r(), use the return parameter. If this parameter is set to TRUE, print_r() will return its output, instead of printing it (which it does by default).
http://uk2.php.net/print_r
If you would like to capture the output of print_r(), use the return parameter. If this parameter is set to TRUE, print_r() will return its output, instead of printing it (which it does by default).
http://uk2.php.net/print_r
LOL! Thanks ncoo - I thought I had put that in, obviously not.....
ASKER
Thank you all but this does not answer my question. I am aware of print_r($zzz,true);
But print_r does NOT return all the same information as var_dump.
Is there anything like var_dump($zzz,true);
?
But print_r does NOT return all the same information as var_dump.
Is there anything like var_dump($zzz,true);
?
Try this:
ob_start();
$zzz=array('111','222',333);
var_dump($zzz);
$qqq = ob_get_clean();
echo $qqq;
What we're doing is using PHP output controls to catch the var_dump and setting the captured output to your qqq value.
ASKER
ncoo, your idea is a hack and not what I am looking for.
Is the consensus that no PHP function is capable of doing what I am asking (without output buffering)?
Is the consensus that no PHP function is capable of doing what I am asking (without output buffering)?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
$zzz=array('111','222',333
$qqq = print_r($zzz);
echo $qqq;
?>