Home >Backend Development >PHP Tutorial >php数组输出的有关问题

php数组输出的有关问题

WBOY
WBOYOriginal
2016-06-13 10:13:19873browse

php数组输出的问题

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->foreach($list as $value){  $this->output .= $value['q_username'];//a  $this->output .= print_r($value);// b}


两个输出语句,a输出空白,b用print_r的方法可以输出数组的结构,有值,名称也是q_username

为啥就输不出来呢

------解决方案--------------------
PHP code
foreach($list as $key=>$value){  $this->output .= $value['q_username'];//a  $this->output .= print_r($value);// b}<br><font color="#e78608">------解决方案--------------------</font><br>把第二行前面的 $this->output .=去掉看看。<br>foreach($list as $value) {  <br>    $this->output .= $value['q_username'];//a<br>    print_r($value); // b<br>  }  <br>echo  $this->output;<br><font color="#e78608">------解决方案--------------------</font><br>
探讨

你的 $value 是二维数组(#2)
用 $this->output .= $value['q_username']; 当然是输出不了的

------解决方案--------------------
探讨

引用:

你的 $value 是二维数组(#2)
用 $this->output .= $value['q_username']; 当然是输出不了的


咦...还是老大眼睛好使啊
Statement:
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