This is a super simple array print, but I'm getting at the end when I use print_r.
<?php
$user_names = array(1, 2, 3, 4);
$results = print_r($user_names);
echo $results;
?>
Then I get:
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
)
1
print_r
already prints the array - there is no need to echo
its return value (which is true
and thus will end up as 1
when converted to a string):
When the return parameter is TRUE, this function will return a string. Otherwise, the return value is TRUE.
The following would work fine, too:
$results = print_r($user_names, true);
echo $results;
It makes no sense at all though unless you don't always display the results right after getting them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With