简体   繁体   English

如何分别访问数组的元素并获取它们

[英]How to access the elements of array individually and fetch them

print_r($que);

output's this: 输出是这样的:

Array ( [0] => Array ( [0] => PHP allows you to send emails directly from a script [1] => How do you get information from a form that is submitted using the "get" method? [2] => In PHP you can use both single quotes ( ) and double quotes ( " " ) for strings: [3] => What does php stands for ? [4] => The PHP syntax is most similar to: [5] => What is the correct way to connect to a MySQL database? [6] => What is the correct way to include the file "time.inc" ? [7] => In PHP, the die() and exit() functions do the exact same thing. [8] => All variables in PHP start with which symbol? [9] => Include files must have the file extension ".inc" ) )

I need to print each element. 我需要打印每个元素。

LIKE $que[0]; 像$ que [0]; and $que[1]; 和$ que [1]; and so on. 等等。

if i does echo "$que[0]"; 如果我确实echo "$que[0]"; output comes out to be Array instead of PHP allows you to send emails directly from a script . 输出结果是Array而不是PHP allows you to send emails directly from a script

$que[0] is an array itself. $que[0]本身就是一个数组。 To access the first element within the first element of $que you need to do $que[0][0] . 要访问$que的第一个元素内的第一个元素,您需要执行$que[0][0]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM