putting print_r results in variable

Php

Php Problem Overview


In PHP I can say:

print_r($var);

What I can't do (at least I don't know how) is:

$var_info = print_r($var);

How can I accomplish the effect of putting the results of a print_r inside a variable?
PHP v5.3.5

Php Solutions


Solution 1 - Php

> When the second parameter is set to > TRUE, print_r() will return the > information rather than print it

$var_info = print_r($var,true);

Solution 2 - Php

$var_info = print_r($var, true);

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionWeb_DesignerView Question on Stackoverflow
Solution 1 - PhpShakti SinghView Answer on Stackoverflow
Solution 2 - PhpElijan SejicView Answer on Stackoverflow