print("<pre>"); // 格式化输出数组 print_r($sites); print("</pre>");
时间: 2024-04-23 11:27:25 浏览: 8
你可以使用`print_r`函数以更易读的形式打印数组。使用`<pre>`标签可以在网页上保留格式,使输出更加清晰。以下是你提供的代码的修改版本:
```php
<?php
$cars = array
(
array("Volvo",100,96),
array("BMW",60,59),
array("Toyota",110,100)
);
echo "<pre>"; // 格式化输出数组
print_r($cars);
echo "</pre>";
?>
```
这样,你将会看到一个格式化的输出结果,其中包含了二维数组`$cars`的内容。
相关问题
$xml =" <root><person><name>John</name><age>30</age></person><person><name>Jane</name><age>25</age></person></root> ";转为数组
可以使用 SimpleXMLElement 类来将 XML 转换为数组:
```php
$xml = "<root><person><name>John</name><age>30</age></person><person><name>Jane</name><age>25</age></person></root>";
// 将 XML 转换为 SimpleXMLElement 对象
$sxml = new SimpleXMLElement($xml);
// 将 SimpleXMLElement 对象转换为数组
$array = json_decode(json_encode($sxml), true);
print_r($array);
```
输出结果:
```
Array
(
[person] => Array
(
[0] => Array
(
[name] => John
[age] => 30
)
[1] => Array
(
[name] => Jane
[age] => 25
)
)
)
```
<property> <name>hive.cli.print.header</name> <value>true</value> </property> <property> <name>hive.cli.print.current.db</name> <value>true</value> </property>
这段代码是Hive的配置文件中的两个属性。这些属性用于配置Hive客户端在执行查询时打印表头和当前数据库的信息。
`hive.cli.print.header`属性设置为`true`,表示在查询结果中打印表头信息。这样,在执行查询时,结果的第一行将显示列名。
`hive.cli.print.current.db`属性设置为`true`,表示在Hive客户端中打印当前所在的数据库。这样,在进入Hive客户端后,会显示当前所在的数据库。
这些属性可以根据需要进行配置,以满足特定的输出需求。