Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何创建这样打印的数组:数组(array(';foo';=>;';bar';)_Php - Fatal编程技术网

Php 如何创建这样打印的数组:数组(array(';foo';=>;';bar';)

Php 如何创建这样打印的数组:数组(array(';foo';=>;';bar';),php,Php,如何创建这样打印的数组: array( array('foo' => 'bar')) 因为: $a = array( array('foo' => 'bar')) 将打印以下内容: Array( [0] => Array ('foo' => 'bar')) print\r始终通过显式显示索引来打印数组。没有办法定制这个。因此,即使它是一个普通的索引数组,它也会显示所有的数字索引 array( array('foo' => 'bar')) 这和 Array(

如何创建这样打印的数组:

array( array('foo' => 'bar'))
因为:

$a = array( array('foo' => 'bar'))
将打印以下内容:

Array( [0] => Array ('foo' => 'bar'))

print\r
始终通过显式显示索引来打印数组。没有办法定制这个。因此,即使它是一个普通的索引数组,它也会显示所有的数字索引

array( array('foo' => 'bar')) 
这和

Array( [0] => Array ('foo' => 'bar'))

另外,
var\u dump($array\u var)
应该可以为你做一个同样漂亮的打印。

数组(数组('foo'=>'bar'))
数组([0]=>数组('foo'=>'bar'))完全一样。
@Mike非常感谢你。(如果你对回答这样的问题不感到羞耻的话,去回答吧,我会接受的。)我现在真的没有时间。如果有人想回答,那就接受他们的回答吧。或者你也可以回答你自己的问题。