Home > Backend Development > PHP Tutorial > php遍历数组$arr,请问下面这个$arr数组的结构是什么样的,怎么输出遍历输出结果: 1 2 3

php遍历数组$arr,请问下面这个$arr数组的结构是什么样的,怎么输出遍历输出结果: 1 2 3

WBOY
Release: 2016-06-23 13:42:48
Original
1189 people have browsed it

用print_r($arr);
输出:Array ( [0] => 1,3,2 )
用var_dump($arr);
输出:array(1) { [0]=> string(5) "1,3,2" } 
for循环输出得到
for ($i = 0; $i              echo $arr[$i];
        }
输出:1,2,3
//逗号竟然也遍历出来的有
请问这个数结构是怎么样的,怎么把我怎么把这个for循环遍历时候去掉逗号呢,
只输出这样的结构:


3


回复讨论(解决方案)

$arr就是一个数组$arr=array('1,2,3')
你可以$arr=explode(',',array('1,2,3'));
再for循环

嗯,是的,谢啦

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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template