Page 1 of 1

Easy question, why does array() have bonus information..

Posted: Fri Jul 09, 2010 12:26 pm
by timotheus
Hello,

So here is my issue.

Code: Select all

<?php
$output = array(1,2,3);
echo print_r($output);
?>
The output of this is:

Array ( [0] => 1 [1] => 2 [2] => 3 ) 1

Where is that extra '1' coming from? It's kind of driving me mad. :)

Thanks.

Re: Easy question, why does array() have bonus information..

Posted: Fri Jul 09, 2010 12:30 pm
by cpetercarter
To print out an array, all you need is print_r() - if you "echo" as well, you will get both the array and the value (1 or true) returned by the print_r() function.

Re: Easy question, why does array() have bonus information..

Posted: Fri Jul 09, 2010 12:32 pm
by timotheus
That makes a lot of sense. I forgot about that. Quite embarrassing. :roll:

I appreciate the quick response, many thanks.