为什么这两个数组会打印不一样。

WBOY
Release: 2016-06-23 14:23:53
Original
1051 people have browsed it

$newsyids=1,3,5,8,7,5,3
$arr1= array($newsyids);
print_r($arr1);

$arr2= array(1,3,5,8,7,5,3);
print_r($arr2);

为什么这两个的打印结果不一样?
请高人指点?

打印arr1的情况是Array ( [0] => 1,3,5,8,7,5,3 )
打印arr2的啥情况是Array ( [0] => 1 [1] => 3 [2] => 5 [3] => 8 [4] => 7 [5] => 5 [6] => 3 )

我想arr1里面的是变量,同时打印结果钥匙arr2的样子,有啥办法吗?


回复讨论(解决方案)

//因为第一个你多加了个array()使得其变为了二维数组$newsyids='1,3,5,8,7,5,3';print_r(explode(",",$newsyids));
Copy after login
Copy after login
Copy after login

//因为第一个你多加了个array()使得其变为了二维数组$newsyids='1,3,5,8,7,5,3';print_r(explode(",",$newsyids));
Copy after login
Copy after login
Copy after login

不是这样理解吧?

如二楼,有引号,就是字符串,一个整体,构建array当然只有一个值。

//因为第一个你多加了个array()使得其变为了二维数组$newsyids='1,3,5,8,7,5,3';print_r(explode(",",$newsyids));
Copy after login
Copy after login
Copy after login

感谢。

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!