Suppose you have an array:
<?php$arr=["PHP", "Chinese", "net"];echo $arr;? >
What will the above code output? Above results you can try again locally.
We typically use Print_r to print an array (Var_dump is also possible, but not structurally clear)
BOOL Print_r (mixed $expression [, BOOL $return])
Please try to print
Print_r ($names);
When the second argument is true, Print_r does not print the array directly, but instead returns the printed content as a string
Echo Print_r ($names, true);
We can use Echo to print a string, integer, float, but we can't use it to print an array.
Arrays are made up of a series of elements, and if you want to print, you should print each element instead of the entire array.
The output of an array of elements in PHP can be achieved through output statements, such as ECHO statements, print statements, and so on. However, this output can only be used to output an element in an array, and the Print_r () function allows you to output the structure of the arrays.
The syntax format is as follows:
BOOL Print_r (mixed expression)
If the function's argument expression is a normal integer, string, or real variable, the variable itself is output. If the parameter is an array, the key values and the order of the elements output all elements in the array.
An instance of the output array of the Print_r () function:
<?phpheader ("content-type:text/html; Charset=utf-8 "), $array = Array (1=>" PHP ",2=>" Chinese ",3=>" net ");p Rint_r ($array); >
The output is:
"Related tutorials Recommended"
1. Related topics: "PHP array"