If an array is printed as ‘Array’, how do you solve it?

Suppose you want to print an array on the screen. So we wrote code like below.
<?php
(print_r (
"<pre>".
get_function($user_id, "some array data")
."</pre>"
));
?>
This is a simple code. And of course we expect the array to be printed well.

What?
That is not what we want to see. But there is no need to panic. Array was printed and that mean the function worked well. The problem is the format of the data we received. The reason for printing ‘array’ is mostly due to data formatting issues.It means that the data we receive is raw data. Encoding is required.
In this situation, we can use json.encode()
.
print_r (
"<pre>".
json_encode(get_function($user_id, "some array data"))
."</pre>"
)
And let’s check that.

Now we can print well.
Remember, if the information type is printed as it is, most of them can be solved by just encoding.