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_ralready prints the array – there is no need toechoits return value (which istrueand thus will end up as1when converted to a string):The following would work fine, too:
It makes no sense at all though unless you don’t always display the results right after getting them.