cs.punk Posted February 6, 2011 Share Posted February 6, 2011 Hey guys it's been a long time, but I am back with php! Anyway here's my dilemma: test.php <?php <?php $name = array('Chris', 'Bob', 'Jack'); $names = print_r($name); ?> Simple enough right? Well although I am not printing/echoing these results to screen it does it automatically. Meaning when I point my browser to test.php it outputs this: Array ( [0] => Chris [1] => Bob [2] => Jack ) Rather than only assigning the value to the $names variable, which is what I would expect it to do. Is this normal behaviour or is there something I can change on php.ini? Thank you! Quote Link to comment Share on other sites More sharing options...
Fergal Andrews Posted February 6, 2011 Share Posted February 6, 2011 Hi cs.punk, You can capture the output of print_r instead of echoing it by adding a return value: print_r($myArray, true); Try this with your code: <?php $name = array('Chris', 'Bob', 'Jack'); $names = print_r($name, true); echo $names; ?> cheers, Fergal Quote Link to comment Share on other sites More sharing options...
cs.punk Posted February 6, 2011 Author Share Posted February 6, 2011 Haha dam I should have read the manual! Thank you! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.