分别用print_r()和var_dump()输出
时间: 2024-05-07 17:16:17 浏览: 72
以下数组:
```
$fruits = array("apple", "banana", "orange", "kiwi");
```
使用print_r()输出:
```
Array
(
[0] => apple
[1] => banana
[2] => orange
[3] => kiwi
)
```
使用var_dump()输出:
```
array(4) {
[0]=>
string(5) "apple"
[1]=>
string(6) "banana"
[2]=>
string(6) "orange"
[3]=>
string(4) "kiwi"
}
```
相关问题
php利用sort()函数,对数组$a=array(20,34,12,54,64,43,7);分别实现print_r和var_dump两种方式升序输出
Sure! Here's the code:
```
$a = array(20, 34, 12, 54, 64, 43, 7);
// Sort the array in ascending order using sort() function
sort($a);
// Print the sorted array using print_r()
print_r($a);
// Print the sorted array using var_dump()
var_dump($a);
```
This will output:
```
Array
(
[0] => 7
[1] => 12
[2] => 20
[3] => 34
[4] => 43
[5] => 54
[6] => 64
)
array(7) {
[0]=>
int(7)
[1]=>
int(12)
[2]=>
int(20)
[3]=>
int(34)
[4]=>
int(43)
[5]=>
int(54)
[6]=>
int(64)
}
```
I hope this helps!
阅读全文