php cannot output arrays directly because echo is used to output strings, not arrays. You can use "print_r($id)" to output an array or use "var_dump($id)" to view the array. Can.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
What should I do if php cannot directly output an array?
Specific question:
php array problem, why can’t the array be output?
$id = array(); $q = $db->query("select * from wp_files where userid='$userid' and is_del=1"); while ($rs = $db->fetch_array($q)) { $id[] = $rs[file_id]; echo $rs[file_id]; echo $id; }
Output $rs[uid] Normally $uid is Array
Output $rs[file_id] Normally $id is Array
Solution:
The array type created by $id
And echo is used to output strings
You can use print_r($id) to output an array
or use the commonly used var_dump($id) to see values and data types.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What should I do if php cannot directly output an array?. For more information, please follow other related articles on the PHP Chinese website!