How to print or echo all the values of an array in PHP?

Today, We want to share with you echo array in php.In this post we will show you associative array in php, hear for php multidimensional array we will give you demo and example for implement.In this post, we will learn about PHP Arrays Example Tutorial For Beginners From Scratch with an example.

How to echo or print an array in PHP?

Also You can use print_r, var_dump and var_export funcations of php:

Example 1: using foreach

foreach($up_comming_movies['data'] as $result) {
    echo $result['type'], '<br>';
}

Free Live Chat for Any Issue

Example 2: using print_r

echo '<pre>'; print_r($up_comming_movies); echo '</pre>';

$up_comming_movies = ["a", "b", "c"];

echo "<pre>";
print_r($up_comming_movies);
echo "</pre>";

Results

Array
(
    [0] => a
    [1] => b
    [2] => c
)

Example 3: using json_encode

echo json_encode($up_comming_movies);

using var_dump();

var_dump($movies);

PHP Arrays Example

<!DOCTYPE html>
<html>
<body>

<?php
$movies = array("TamilRokers", "bolly4u", "4cgandhi"); 
echo "I like " . $movies[0] . ", " . $movies[1] . " and " . $movies[2] . ".";
?>

</body>
</html>

Example of Displaying the PHP Array Values

Also Read This πŸ‘‰   how to insert multiple image in database using codeigniter?

<?php
$up_comming_movies = array("TamilRokers", "bolly4u", "4cgandhi", "Khatrimaza", "movimaza");
 
// Loop through up_comming_movies array
foreach($up_comming_movies as $value){
    echo $value . "<br>";
}
?>

I hope you get an idea about php get array value by key.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Rate this post