Home » Php » php – How can I print all the values of an array?

php – How can I print all the values of an array?

Posted by: admin July 12, 2020 Leave a comment

Questions:

I have an array and print_r won’t display the raw text, how can I print all the values in an array (e.g. pie)

How to&Answers:

So many ways to do it…

foreach ($array as $item) {
    echo $item;
}

echo join(', ', $array);

array_walk($array, create_function('$a', 'echo $a;'));

Answer:

Maybe you just need some <pre> tags:

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

Answer:

<?php
$len=count($pie);
for ($i=0;$i<$len;$i++)
   echo $pie[$i];
?>