Example 1 — Printing an Array
Print a simple array, then a plain string.
<?php
$fruits = ['apple', 'banana'];
print_r($fruits);
print_r('Hello');
echo PHP_EOL; How It Works
- The array has two items. PHP numbers the keys 0 and 1 automatically.
- print_r() prints Array and then each key and value. The format is key => value inside parentheses.
- A string is printed as it is. print_r('Hello') shows only Hello with no quotes.
- echo PHP_EOL adds the final new line. print_r() does not add one after plain strings.

