Php, ordered-arrays

In lesson Accessing an Element, when on the end of the practice I type this (last line):

<?php
namespace Codecademy;

$round_one = ["X", "X", "first winner"];

$round_two = ["second winner", "X", "X", "X"];

$round_three = ["X", "X", "X", "X", "third winner"];

// Write your code below:
$winners = [$round_one[2], $round_two[0], $round_three[4]];
echo "Content of the winners array is: ".print_r(implode(", ", $winners));

I get:
first winner, second winner, third winnerContent of the winners array is: 1

Why? And why is that number one at the end?

print_r() is a form of echo, so we don’t have to echo it.

echo implode(', ', $winners);

vs.

print_r($winners);

We cannot concatenate a string with print_r.

echo '\nWinners:\n';
print_r($winners);
1 Like

I understand, correct code is:
print_r("Content of the winners array is: β€œ.implode(”, ", $winners));
Thanks!

1 Like