What should I do if php cannot directly output an array?

藏色散人
Release: 2023-03-10 22:18:02
Original
1993 people have browsed it

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.

What should I do if php cannot directly output an array?

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; }
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!